redis / go-redis

Redis Go client
https://redis.uptrace.dev
BSD 2-Clause "Simplified" License
19.6k stars 2.31k forks source link

ReadFromAny (master+replica) without cluster mode (Master-Replica setup) #2995

Open singh-bhawani opened 1 month ago

singh-bhawani commented 1 month ago

Right now, with go-redis, we can't read from both the Master and its Replica without being in cluster mode. Also, when we use "ReplicaOnly", it randomly chooses Replica to read. This causes a problem because caching is mainly used for read heavy usecase, which means the Master only used for write throughput and it's resource are underutilized.

To solve this, I added "ReadFromAny" to "FailoverOptions". This means that read-only commands will come from both Replicas as well as Master. This way, we can make better use of the caching resource.