Search code examples
redisreplicationpartitioningredis-cluster

Read directly from a replica inside Redis cluster


I want to read directly from a replica inside a Redis cluster but I am getting redirected even if the key actually exist inside the Redis node.

redis cluster replica read

Checked READONLY command docs. However, that is seemed to be ignored in case of Redis Cluster.

How should I configure the Redis cluster so that I can directly read from a replica node for the reads issue against its hash slots? I am OK to read stale data in this case.


Solution

  • The READONLY command (as well as the READWRITE command that counteracts it) are applicable per connection in a clustered environment.

    While READWRITE is the default behavior, in order to change that you'll need to call READONLY in the context of the connection that you're using.