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