READONLY(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

✨ READONLY ✨

okay bestie, welcome to the READONLY page of the Valkey Command Manual (that's the 3valkey one, iykyk) β€” this is the glow-up guide to reading from replicas without the drama πŸ’–


🌸 NAME 🌸

readonly β€” turns on read-only queries for a connection to a Valkey replica node. that's it, that's the vibe πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

READONLY

no args, no flags, just the word. iconic minimalism honestly ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically: this command enables read queries for a connection to a Valkey replica node. that's the whole point 🫢

in cluster mode, replica nodes will redirect clients to the authoritative primary for the hash slot involved in a given command. BUT β€” and this is the slay part β€” clients can use replicas to scale reads using the READONLY command. main character energy for your read throughput, no cap πŸ”₯

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. like, we're here for the vibes and the reads, not the writes bestie.

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:

  1. the client sent a command about hash slots never served by the primary of this replica.
  2. the cluster was reconfigured (for example resharded) and the replica is no longer able to serve commands for a given hash slot. 😭
  3. 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. (so if you're on an old version, that's a vibe check you're failing, ngl)

in standalone mode, by default, clients accessing a replica node can execute read queries (which might read stale data) without entering readonly mode. so it just works, no extra steps πŸŽ€

since Valkey 8.0, if a client in standalone mode uses the valkey-client-capa(7) 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. periodt. ✨


πŸ’Œ REPLY πŸ’Œ

valkey-protocol(7) Simple string reply: OK.


πŸ’« COMPLEXITY πŸ’«

O(1) β€” constant time, always serving, never stressing πŸ’…


πŸ‘‘ ACL CATEGORIES πŸ‘‘

  • @connection
  • @fast

🌈 HISTORY 🌈

  • Available since: 3.0.0

🧚 SEE ALSO 🧚


version 9.0.0, dated 2025-10-21, and it's the READONLY(3valkey) page πŸ¦‹ thanks for reading bestie, go scale those reads, mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from