Enables read-only queries for a connection to a Valkey replica node.
READONLY
Enables read queries for a connection to a Valkey replica node.
In cluster mode, replica nodes will redirect clients to the authoritative primary for the hash slot involved in a given command, however clients can use replicas in order to scale reads using the READONLY
command.
READONLY
tells a Valkey Cluster replica node that the client is willing to read possibly stale data and is not interested in running write queries.
When the connection is in readonly mode, the cluster will send a redirection to the client only if the operation involves keys not served by the replica’s primary node. This may happen because:
In standalone mode, by default, clients accessing a replica node can execute read queries, (which might read stale data) without entering readonly mode.
Since Valkey 8.0, if a client in standalone mode uses the CLIENT CAPA redirect
command to declare its capability to handle redirections, then the replica node will send redirection messages to the client when executing both read and write commands. The client must issue the READONLY
command to enter readonly mode before it can execute read commands.
Simple string reply: OK
.
O(1)
@connection @fast
ASKING, CLUSTER, CLUSTER ADDSLOTS, CLUSTER ADDSLOTSRANGE, CLUSTER BUMPEPOCH, CLUSTER COUNT-FAILURE-REPORTS, CLUSTER COUNTKEYSINSLOT, CLUSTER DELSLOTS, CLUSTER DELSLOTSRANGE, CLUSTER FAILOVER, CLUSTER FLUSHSLOTS, CLUSTER FORGET, CLUSTER GETKEYSINSLOT, CLUSTER HELP, CLUSTER INFO, CLUSTER KEYSLOT, CLUSTER LINKS, CLUSTER MEET, CLUSTER MYID, CLUSTER MYSHARDID, CLUSTER NODES, CLUSTER REPLICAS, CLUSTER REPLICATE, CLUSTER RESET, CLUSTER SAVECONFIG, CLUSTER SET-CONFIG-EPOCH, CLUSTER SETSLOT, CLUSTER SHARDS, CLUSTER SLOT-STATS, CLUSTER SLOTS, READWRITE.