|
|
@ -31,7 +31,23 @@ func NewRedisHelper(master string, address ...string) *RedisHelper { |
|
|
|
} |
|
|
|
|
|
|
|
func (the *RedisHelper) InitialCluster(master string, address ...string) { |
|
|
|
var opts *redis.UniversalOptions |
|
|
|
if master != "" { |
|
|
|
opts = &redis.UniversalOptions{Addrs: address, MasterName: "mymaster", PoolSize: 10} |
|
|
|
} else { |
|
|
|
opts = &redis.UniversalOptions{Addrs: address, PoolSize: 10} |
|
|
|
} |
|
|
|
|
|
|
|
the.rdb = redis.NewUniversalClient(opts) |
|
|
|
if the.rdb == nil { |
|
|
|
log.Fatal("Failed to initialize Redis client") |
|
|
|
} |
|
|
|
|
|
|
|
log.Printf("Redis client initialized with addresses: %s", address) |
|
|
|
the.isReady = true |
|
|
|
} |
|
|
|
|
|
|
|
func (the *RedisHelper) InitialCluster_old(master string, address ...string) { |
|
|
|
if master != "" { |
|
|
|
the.rdb = redis.NewUniversalClient(&redis.UniversalOptions{ |
|
|
|
Addrs: address, |
|
|
|