|
@@ -10,6 +10,7 @@ import (
|
|
|
// RedisConfig config
|
|
|
type RedisConfig struct {
|
|
|
Addr string
|
|
|
+ UserName string
|
|
|
Password string
|
|
|
DB int
|
|
|
DialTimeout time.Duration
|
|
@@ -24,6 +25,7 @@ type RedisClusterConfig struct {
|
|
|
// A seed list of host:port addresses of cluster nodes.
|
|
|
Addrs []string
|
|
|
|
|
|
+ UserName string
|
|
|
Password string
|
|
|
DB int
|
|
|
|
|
@@ -82,6 +84,7 @@ func SetRedisClusterConfig(cfg RedisClusterConfig) {
|
|
|
func NewRedisCache() *RedisCache {
|
|
|
client := redis.NewClient(&redis.Options{
|
|
|
Addr: redisConfig.Addr,
|
|
|
+ Username: redisConfig.UserName,
|
|
|
Password: redisConfig.Password,
|
|
|
DialTimeout: redisConfig.DialTimeout,
|
|
|
ReadTimeout: redisConfig.ReadTimeout,
|
|
@@ -99,6 +102,7 @@ func NewRedisClusterCache() *RedisCache {
|
|
|
var config redis.ClusterOptions
|
|
|
|
|
|
config.Addrs = redisClusterConfig.Addrs
|
|
|
+ config.Username = redisClusterConfig.UserName
|
|
|
config.Password = redisClusterConfig.Password
|
|
|
|
|
|
config.DialTimeout = redisClusterConfig.DialTimeout
|