role

ROLE

ROLE

Provide information on the role of a Redis instance in the context of replication, by returning if the instance is currently a master, slave, or sentinel. The command also returns additional information about the state of the replication (if the role is master or slave) or the list of monitored master names (if the role is sentinel).

Output format

The command returns an array of elements. The first element is the role of the instance, as one of the following three strings:

  • "master"
  • "slave"
  • "sentinel"

The additional elements of the array depends on the role.

Master output

An example of output when ROLE is called in a master instance:

1) .html?lang=en"master"
2) (integer) 3129659
3) 1) 1) "127.0.0.1"
      2) "900