Skip to content

Commit

Permalink
Update condition for Redis replica client creation
Browse files Browse the repository at this point in the history
The condition for creating a new Redis replica client has been updated to first check if the Replica.Address field is not empty. This ensures that we do not attempt to create a replica client unless a replica address is specified.

Signed-off-by: Christian Roessner <c@roessner.co>
  • Loading branch information
Christian Roessner committed Jun 14, 2024
1 parent 9b76fac commit e044c4d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/rediscli/cient.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ func NewRedisReplicaClient() redis.UniversalClient {
return newRedisFailoverClient(redisCfg, true)
}

if redisCfg.Master.Address != redisCfg.Replica.Address {
return newRedisClient(redisCfg, redisCfg.Replica.Address)
if redisCfg.Replica.Address != "" {
if redisCfg.Master.Address != redisCfg.Replica.Address {
return newRedisClient(redisCfg, redisCfg.Replica.Address)
}
}

return nil
Expand Down

0 comments on commit e044c4d

Please sign in to comment.