Skip to content

Commit

Permalink
Add the Protocol attribute to the Redis configuration (#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxing113 authored Oct 30, 2023
1 parent 3ea61d0 commit ab5ab4c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/nosql/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions database/gredis/gredis_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit ab5ab4c

Please sign in to comment.