fix: can not switch db in sentinel mode #144
This commit is contained in:
parent
f1e1a89baf
commit
094705e87d
|
@ -144,9 +144,6 @@ func (c *connectionService) buildOption(config types.ConnectionConfig) (*redis.O
|
|||
option.Addr = fmt.Sprintf("%s:%d", config.Addr, config.Port)
|
||||
}
|
||||
}
|
||||
if config.LastDB > 0 {
|
||||
option.DB = config.LastDB
|
||||
}
|
||||
if sshClient != nil {
|
||||
option.Dialer = func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
return sshClient.Dial(network, addr)
|
||||
|
@ -181,6 +178,10 @@ func (c *connectionService) createRedisClient(config types.ConnectionConfig) (re
|
|||
option.Password = config.Sentinel.Password
|
||||
}
|
||||
|
||||
if config.LastDB > 0 {
|
||||
option.DB = config.LastDB
|
||||
}
|
||||
|
||||
rdb := redis.NewClient(option)
|
||||
if config.Cluster.Enable {
|
||||
// connect to cluster
|
||||
|
|
Loading…
Reference in New Issue