Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

READONLY

Last updated
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.

Simple string OK in RESP2 and RESP3. With cluster mode off: ERR This instance has cluster support disabled.

10.0.0.4:6379> GET user:1000
(error) MOVED 1649 10.0.0.1:6379
10.0.0.4:6379> READONLY
OK
10.0.0.4:6379> GET user:1000
"alice"
10.0.0.4:6379> SET user:1000 "bob"
(error) MOVED 1649 10.0.0.1:6379

Same as Redis 7 and Valkey 8.

READWRITE, ASKING, CLUSTER SLOTS

In a cluster: Keys, slots and commands in a cluster