mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
Add the Protocol attribute to the Redis configuration (#3109)
This commit is contained in:
@ -61,6 +61,7 @@ func New(config *gredis.Config) *Redis {
|
||||
WriteTimeout: config.WriteTimeout,
|
||||
MasterName: config.MasterName,
|
||||
TLSConfig: config.TLSConfig,
|
||||
Protocol: config.Protocol,
|
||||
}
|
||||
|
||||
var client redis.UniversalClient
|
||||
|
||||
@ -40,6 +40,7 @@ type Config struct {
|
||||
TLSConfig *tls.Config `json:"-"` // TLS Config to use. When set TLS will be negotiated.
|
||||
SlaveOnly bool `json:"slaveOnly"` // Route all commands to slave read-only nodes.
|
||||
Cluster bool `json:"cluster"` // Specifies whether cluster mode be used.
|
||||
Protocol int `json:"protocol"` // Specifies the RESP version (Protocol 2 or 3.)
|
||||
}
|
||||
|
||||
const (
|
||||
@ -102,6 +103,9 @@ func ConfigFromMap(m map[string]interface{}) (config *Config, err error) {
|
||||
if config.MaxConnLifetime < time.Second {
|
||||
config.MaxConnLifetime = config.MaxConnLifetime * time.Second
|
||||
}
|
||||
if config.Protocol != 2 && config.Protocol != 3 {
|
||||
config.Protocol = 3
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user