Merge afda87532c into 110d51d1d7
This commit is contained in:
commit
6b38a0142f
|
|
@ -109,6 +109,9 @@ func buildSentinelClient(opts options.RedisStoreOptions) (Client, error) {
|
||||||
if opts.Username != "" {
|
if opts.Username != "" {
|
||||||
opt.Username = opts.Username
|
opt.Username = opts.Username
|
||||||
}
|
}
|
||||||
|
if opts.IdleTimeout > 0 {
|
||||||
|
opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
if err := setupTLSConfig(opts, opt); err != nil {
|
if err := setupTLSConfig(opts, opt); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -118,10 +121,10 @@ func buildSentinelClient(opts options.RedisStoreOptions) (Client, error) {
|
||||||
MasterName: opts.SentinelMasterName,
|
MasterName: opts.SentinelMasterName,
|
||||||
SentinelAddrs: addrs,
|
SentinelAddrs: addrs,
|
||||||
SentinelPassword: opts.SentinelPassword,
|
SentinelPassword: opts.SentinelPassword,
|
||||||
Username: opts.Username,
|
Username: opt.Username,
|
||||||
Password: opts.Password,
|
Password: opt.Password,
|
||||||
TLSConfig: opt.TLSConfig,
|
TLSConfig: opt.TLSConfig,
|
||||||
ConnMaxIdleTime: time.Duration(opts.IdleTimeout) * time.Second,
|
ConnMaxIdleTime: opt.ConnMaxIdleTime,
|
||||||
})
|
})
|
||||||
return newClient(client), nil
|
return newClient(client), nil
|
||||||
}
|
}
|
||||||
|
|
@ -139,6 +142,9 @@ func buildClusterClient(opts options.RedisStoreOptions) (Client, error) {
|
||||||
if opts.Username != "" {
|
if opts.Username != "" {
|
||||||
opt.Username = opts.Username
|
opt.Username = opts.Username
|
||||||
}
|
}
|
||||||
|
if opts.IdleTimeout > 0 {
|
||||||
|
opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
if err := setupTLSConfig(opts, opt); err != nil {
|
if err := setupTLSConfig(opts, opt); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -146,10 +152,10 @@ func buildClusterClient(opts options.RedisStoreOptions) (Client, error) {
|
||||||
|
|
||||||
client := redis.NewClusterClient(&redis.ClusterOptions{
|
client := redis.NewClusterClient(&redis.ClusterOptions{
|
||||||
Addrs: addrs,
|
Addrs: addrs,
|
||||||
Username: opts.Username,
|
Username: opt.Username,
|
||||||
Password: opts.Password,
|
Password: opt.Password,
|
||||||
TLSConfig: opt.TLSConfig,
|
TLSConfig: opt.TLSConfig,
|
||||||
ConnMaxIdleTime: time.Duration(opts.IdleTimeout) * time.Second,
|
ConnMaxIdleTime: opt.ConnMaxIdleTime,
|
||||||
})
|
})
|
||||||
return newClusterClient(client), nil
|
return newClusterClient(client), nil
|
||||||
}
|
}
|
||||||
|
|
@ -168,13 +174,14 @@ func buildStandaloneClient(opts options.RedisStoreOptions) (Client, error) {
|
||||||
if opts.Username != "" {
|
if opts.Username != "" {
|
||||||
opt.Username = opts.Username
|
opt.Username = opts.Username
|
||||||
}
|
}
|
||||||
|
if opts.IdleTimeout > 0 {
|
||||||
|
opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
if err := setupTLSConfig(opts, opt); err != nil {
|
if err := setupTLSConfig(opts, opt); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
|
|
||||||
|
|
||||||
client := redis.NewClient(opt)
|
client := redis.NewClient(opt)
|
||||||
return newClient(client), nil
|
return newClient(client), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue