@@ -109,6 +109,9 @@ func buildSentinelClient(opts options.RedisStoreOptions) (Client, error) {
109109 if opts.Username != "" {
110110 opt.Username = opts.Username
111111 }
112+ if opts.IdleTimeout > 0 {
113+ opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
114+ }
112115
113116 if err := setupTLSConfig(opts, opt); err != nil {
114117 return nil, err
@@ -118,10 +121,10 @@ func buildSentinelClient(opts options.RedisStoreOptions) (Client, error) {
118121 MasterName: opts.SentinelMasterName,
119122 SentinelAddrs: addrs,
120123 SentinelPassword: opts.SentinelPassword,
121− Username: opts.Username,
122− Password: opts.Password,
124+ Username: opt.Username,
125+ Password: opt.Password,
123126 TLSConfig: opt.TLSConfig,
124− ConnMaxIdleTime: time.Duration(opts.IdleTimeout) * time.Second,
127+ ConnMaxIdleTime: opt.ConnMaxIdleTime,
125128 })
126129 return newClient(client), nil
127130}
@@ -139,6 +142,9 @@ func buildClusterClient(opts options.RedisStoreOptions) (Client, error) {
139142 if opts.Username != "" {
140143 opt.Username = opts.Username
141144 }
145+ if opts.IdleTimeout > 0 {
146+ opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
147+ }
142148
143149 if err := setupTLSConfig(opts, opt); err != nil {
144150 return nil, err
@@ -146,10 +152,10 @@ func buildClusterClient(opts options.RedisStoreOptions) (Client, error) {
146152
147153 client := redis.NewClusterClient(&redis.ClusterOptions{
148154 Addrs: addrs,
149− Username: opts.Username,
150− Password: opts.Password,
155+ Username: opt.Username,
156+ Password: opt.Password,
151157 TLSConfig: opt.TLSConfig,
152− ConnMaxIdleTime: time.Duration(opts.IdleTimeout) * time.Second,
158+ ConnMaxIdleTime: opt.ConnMaxIdleTime,
153159 })
154160 return newClusterClient(client), nil
155161}
@@ -168,13 +174,14 @@ func buildStandaloneClient(opts options.RedisStoreOptions) (Client, error) {
168174 if opts.Username != "" {
169175 opt.Username = opts.Username
170176 }
177+ if opts.IdleTimeout > 0 {
178+ opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
179+ }
171180
172181 if err := setupTLSConfig(opts, opt); err != nil {
173182 return nil, err
174183 }
175184
176− opt.ConnMaxIdleTime = time.Duration(opts.IdleTimeout) * time.Second
177−
178185 client := redis.NewClient(opt)
179186 return newClient(client), nil
180187}