From dad785ca05a0965c76ea5d67528e9fd0b855a381 Mon Sep 17 00:00:00 2001 From: yfh Date: Tue, 12 Nov 2024 14:41:08 +0800 Subject: [PATCH] =?UTF-8?q?(*)Redis=E8=AE=BE=E7=BD=AEPoolSize=EF=BC=9A10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- redisHelper.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/redisHelper.go b/redisHelper.go index 4230b0f..62e20f8 100644 --- a/redisHelper.go +++ b/redisHelper.go @@ -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,