refactor(redis): add NonBlock config, disable redis ping by default (#3073)

This commit is contained in:
cong
2023-03-29 10:28:12 +08:00
committed by GitHub
parent ca4ce7bce8
commit 95b85336d6
5 changed files with 98 additions and 14 deletions

View File

@@ -1,6 +1,9 @@
package redis
import "errors"
import (
"errors"
"time"
)
var (
// ErrEmptyHost is an error that indicates no redis host is set.
@@ -9,17 +12,18 @@ var (
ErrEmptyType = errors.New("empty redis type")
// ErrEmptyKey is an error that indicates no redis key is set.
ErrEmptyKey = errors.New("empty redis key")
// ErrPing is an error that indicates ping failed.
ErrPing = errors.New("ping redis failed")
)
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:",optional"`
Host string
Type string `json:",default=node,options=node|cluster"`
Pass string `json:",optional"`
Tls bool `json:",optional"`
NonBlock bool `json:",default=true"`
// PingTimeout is the timeout for ping redis.
PingTimeout time.Duration `json:",default=1s"`
}
// A RedisKeyConf is a redis config with key.