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.

ROLE

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

An array, in RESP2 and RESP3, whose first element is the role.

On a primary, three elements:

  1. master
  2. The replication offset, an integer.
  3. 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:

  1. slave
  2. The primary’s host.
  3. The primary’s client port, an integer.
  4. The link state: connecting (connecting to the primary), sync (receiving the full data set), connected (streaming changes), or connect (not connected).
  5. The replication offset applied, an integer.

On a primary with one replica:

127.0.0.1:6379> ROLE
1) "master"
2) (integer) 3129659
3) 1) 1) "10.0.0.6"
2) "6379"
3) "3129545"

On its replica:

10.0.0.6:6379> ROLE
1) "slave"
2) "10.0.0.5"
3) (integer) 6379
4) "connected"
5) (integer) 3129659

Same reply shapes as Redis 7 and Valkey 8 for primaries and replicas. HotKV has no Sentinel, so the sentinel role never appears.

INFO (replication), REPLICAOF, WAIT, replication

In a cluster: Replicas and failover