Skip to content

Commit

Permalink
fix: for cluster node, when prefer_replica set to true can not get be…
Browse files Browse the repository at this point in the history
…st replica (#841)
  • Loading branch information
ntuwang authored Jul 12, 2024
1 parent 040c64f commit 5c11f28
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/client/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func NewRedisClient(ctx context.Context, address string, username string, passwo
// get best replica
if replica {
replicaInfo := getReplicaAddr(reply)
// slave node return BestReplica is none,set value by address
if replicaInfo.BestReplica == "" {
replicaInfo.BestReplica = address
}
log.Infof("best replica: %s", replicaInfo.BestReplica)
r = NewRedisClient(ctx, replicaInfo.BestReplica, username, password, Tls, false)
}
Expand Down

0 comments on commit 5c11f28

Please sign in to comment.