fix: dont override parameters set in redis uri
This commit is contained in:
		
							parent
							
								
									8afb047e01
								
							
						
					
					
						commit
						afda87532c
					
				|  | @ -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 | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue