From 24073969a1a11acd282db702c0b741611f47ec8c Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sat, 8 Feb 2025 12:21:35 +0800 Subject: [PATCH] fix: redis username not working in redis v7 (#4632) --- core/stores/redis/redisblockingnode.go | 2 ++ core/stores/redis/redisclientmanager.go | 1 + core/stores/redis/redisclustermanager.go | 1 + 3 files changed, 4 insertions(+) diff --git a/core/stores/redis/redisblockingnode.go b/core/stores/redis/redisblockingnode.go index 6e60fa212..1152869b7 100644 --- a/core/stores/redis/redisblockingnode.go +++ b/core/stores/redis/redisblockingnode.go @@ -21,6 +21,7 @@ func CreateBlockingNode(r *Redis) (ClosableNode, error) { case NodeType: client := red.NewClient(&red.Options{ Addr: r.Addr, + Username: r.User, Password: r.Pass, DB: defaultDatabase, MaxRetries: maxRetries, @@ -32,6 +33,7 @@ func CreateBlockingNode(r *Redis) (ClosableNode, error) { case ClusterType: client := red.NewClusterClient(&red.ClusterOptions{ Addrs: splitClusterAddrs(r.Addr), + Username: r.User, Password: r.Pass, MaxRetries: maxRetries, PoolSize: 1, diff --git a/core/stores/redis/redisclientmanager.go b/core/stores/redis/redisclientmanager.go index 14e608716..9be0065bd 100644 --- a/core/stores/redis/redisclientmanager.go +++ b/core/stores/redis/redisclientmanager.go @@ -31,6 +31,7 @@ func getClient(r *Redis) (*red.Client, error) { } store := red.NewClient(&red.Options{ Addr: r.Addr, + Username: r.User, Password: r.Pass, DB: defaultDatabase, MaxRetries: maxRetries, diff --git a/core/stores/redis/redisclustermanager.go b/core/stores/redis/redisclustermanager.go index 5013de83c..6cd9420ba 100644 --- a/core/stores/redis/redisclustermanager.go +++ b/core/stores/redis/redisclustermanager.go @@ -28,6 +28,7 @@ func getCluster(r *Redis) (*red.ClusterClient, error) { } store := red.NewClusterClient(&red.ClusterOptions{ Addrs: splitClusterAddrs(r.Addr), + Username: r.User, Password: r.Pass, MaxRetries: maxRetries, MinIdleConns: idleConns,