ROLE
ROLE
- Group
- Server
- Complexity
- O(N) where N is the number of replicas
- Arity
- 1 (exactly, counting the command name)
- Flags
- read-only, fast, loading, stale
- HotKV Cloud
- All plans
- On-Premise
- no license needed
ROLE tells a client whether it is talking to a primary or a replica, and
gives the replication details that go with it. Client libraries and proxies
use it to find the primary. As in Redis, the roles are reported as master
and slave.
Return value
Section titled “Return value”An array, in RESP2 and RESP3, whose first element is the role.
On a primary, three elements:
master- The replication offset, an integer.
- An array with one entry per connected replica: its IP address, the port its clients use, and its acknowledged offset, all as bulk strings.
On a replica, five elements:
slave- The primary’s host.
- The primary’s client port, an integer.
- The link state:
connecting(connecting to the primary),sync(receiving the full data set),connected(streaming changes), orconnect(not connected). - The replication offset applied, an integer.
Examples
Section titled “Examples”On a primary with one replica:
127.0.0.1:6379> ROLE1) "master"2) (integer) 31296593) 1) 1) "10.0.0.6" 2) "6379" 3) "3129545"On its replica:
10.0.0.6:6379> ROLE1) "slave"2) "10.0.0.5"3) (integer) 63794) "connected"5) (integer) 3129659Compatibility
Section titled “Compatibility”Same reply shapes as Redis 7 and Valkey 8 for primaries and replicas. HotKV
has no Sentinel, so the sentinel role never appears.
See also
Section titled “See also”INFO (replication), REPLICAOF,
WAIT, replication
In a cluster: Replicas and failover
Was this page helpful?
Thanks for the feedback.