3

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.

tugberk
  • 57,477
  • 67
  • 243
  • 335
  • 2
    You need to issue the `READONLY` command in same connection to the replica, before the get request. Have you tried that? – Itamar Haber Mar 10 '19 at 17:27
  • @ItamarHaber oh, nice! that actually worked, thanks a lot! Please put it as an answer and I will accept it! – tugberk Mar 10 '19 at 23:27

1 Answers1

3

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.

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117