This commit is contained in:
Richard Hagen 2025-10-28 10:29:13 +01:00 committed by GitHub
commit 6b38a0142f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 8 deletions

View File

@ -109,6 +109,9 @@ func buildSentinelClient(opts options.RedisStoreOptions) (Client, error) {
if 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 {
return nil, err
@ -118,10 +121,10 @@ func buildSentinelClient(opts options.RedisStoreOptions) (Client, error) {
MasterName: opts.SentinelMasterName,
SentinelAddrs: addrs,
SentinelPassword: opts.SentinelPassword,
Username: opts.Username,
Password: opts.Password,
Username: opt.Username,
Password: opt.Password,
TLSConfig: opt.TLSConfig,
ConnMaxIdleTime: time.Duration(opts.IdleTimeout) * time.Second,
ConnMaxIdleTime: opt.ConnMaxIdleTime,
})
return newClient(client), nil
}
@ -139,6 +142,9 @@ func buildClusterClient(opts options.RedisStoreOptions) (Client, error) {
if 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 {
return nil, err
@ -146,10 +152,10 @@ func buildClusterClient(opts options.RedisStoreOptions) (Client, error) {
client := redis.NewClusterClient(&redis.ClusterOptions{
Addrs: addrs,
Username: opts.Username,
Password: opts.Password,
Username: opt.Username,
Password: opt.Password,
TLSConfig: opt.TLSConfig,
ConnMaxIdleTime: time.Duration(opts.IdleTimeout) * time.Second,
ConnMaxIdleTime: opt.ConnMaxIdleTime,
})
return newClusterClient(client), nil
}
@ -168,13 +174,14 @@ func buildStandaloneClient(opts options.RedisStoreOptions) (Client, error) {
if 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 {
return nil, err
}
opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
client := redis.NewClient(opt)
return newClient(client), nil
}