READONLY
READONLY
- Group
- Cluster
- Complexity
- O(1)
- Arity
- 1 (exactly, counting the command name)
- Flags
- fast
- HotKV Cloud
- All plans
- On-Premise
- no license needed
In a cluster, a replica normally answers every command on a key with
-MOVED to its primary. After READONLY, the connection may read keys of the
slots its replica’s primary serves directly from the replica, which spreads
read load across the replicas. Writes still get -MOVED to the primary.
Data read from a replica can be slightly behind the primary, since replication is asynchronous. The setting lasts for the connection until READWRITE or the connection closes.
Return value
Section titled “Return value”Simple string OK in RESP2 and RESP3. With cluster mode off:
ERR This instance has cluster support disabled.
Examples
Section titled “Examples”10.0.0.4:6379> GET user:1000(error) MOVED 1649 10.0.0.1:637910.0.0.4:6379> READONLYOK10.0.0.4:6379> GET user:1000"alice"10.0.0.4:6379> SET user:1000 "bob"(error) MOVED 1649 10.0.0.1:6379Compatibility
Section titled “Compatibility”Same as Redis 7 and Valkey 8.
See also
Section titled “See also”READWRITE, ASKING, CLUSTER SLOTS
In a cluster: Keys, slots and commands in a cluster
Was this page helpful?
Thanks for the feedback.