readonly.3valkey - Man Page
Enables read-only queries for a connection to a Valkey replica node.
Synopsis
READONLY
Description
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:
- The client sent a command about hash slots never served by the primary of this replica.
- The cluster was reconfigured (for example resharded) and the replica is no longer able to serve commands for a given hash slot.
- Since Valkey 8.0, if a slot migration is ongoing. In this case the replica can return an ASK redirect or a TRYAGAIN error reply. In earlier versions, replicas are not aware of ongoing slot migrations.
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.
Reply
valkey-protocol(7) Simple string reply: OK
.
Complexity
O(1)
Acl Categories
@connection @fast
History
- Available since: 3.0.0
See Also
asking(3valkey), cluster(3valkey), cluster-addslots(3valkey), cluster-addslotsrange(3valkey), cluster-bumpepoch(3valkey), cluster-count-failure-reports(3valkey), cluster-countkeysinslot(3valkey), cluster-delslots(3valkey), cluster-delslotsrange(3valkey), cluster-failover(3valkey), cluster-flushslots(3valkey), cluster-forget(3valkey), cluster-getkeysinslot(3valkey), cluster-help(3valkey), cluster-info(3valkey), cluster-keyslot(3valkey), cluster-links(3valkey), cluster-meet(3valkey), cluster-myid(3valkey), cluster-myshardid(3valkey), cluster-nodes(3valkey), cluster-replicas(3valkey), cluster-replicate(3valkey), cluster-reset(3valkey), cluster-saveconfig(3valkey), cluster-set-config-epoch(3valkey), cluster-setslot(3valkey), cluster-shards(3valkey), cluster-slots(3valkey), readwrite(3valkey)