feat: slow threshold customizable in redis (#1187)
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/conf"
|
||||
)
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
// ErrEmptyHost is an error that indicates no redis host is set.
|
||||
@@ -19,11 +14,10 @@ var (
|
||||
type (
|
||||
// A RedisConf is a redis config.
|
||||
RedisConf struct {
|
||||
Host string
|
||||
Type string `json:",default=node,options=node|cluster"`
|
||||
Pass string `json:",optional"`
|
||||
Tls bool `json:",default=false,options=true|false"`
|
||||
SlowThreshold time.Duration `json:",default=100ms"`
|
||||
Host string
|
||||
Type string `json:",default=node,options=node|cluster"`
|
||||
Pass string `json:",optional"`
|
||||
Tls bool `json:",default=false,options=true|false"`
|
||||
}
|
||||
|
||||
// A RedisKeyConf is a redis config with key.
|
||||
@@ -42,9 +36,6 @@ func (rc RedisConf) NewRedis() *Redis {
|
||||
if len(rc.Pass) > 0 {
|
||||
opts = append(opts, WithPass(rc.Pass))
|
||||
}
|
||||
if rc.SlowThreshold > 0 {
|
||||
opts = append(opts, WithSlowThreshold(conf.CheckedDuration(rc.SlowThreshold)))
|
||||
}
|
||||
if rc.Tls {
|
||||
opts = append(opts, WithTLS())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user