CLUSTER SLOTS

    Time complexity: O(N) where N is the total number of Cluster nodes

    returns details about which cluster slots map to which Redis instances. The command is suitable to be used by Redis Cluster client libraries implementations in order to retrieve (or update when a redirection is received) the map associating cluster hash slots with actual nodes network coordinates (composed of an IP address and a TCP port), so that when a command is received, it can be sent to what is likely the right instance for the keys specified in the command.

    • Start slot range
    • End slot range
    • Master for slot range represented as nested IP/Port array
    • First replica of master for slot range
    • Second replica
    • …continues until all replicas for this master are returned.

    Each result includes all active replicas of the master instance for the listed slot range. Failed replicas are not returned.

    The third nested reply is guaranteed to be the IP/Port pair of the master instance for the slot range. All IP/Port pairs after the third nested reply are replicas of the master.

    Warning: Newer versions of Redis Cluster will output, for each Redis instance, not just the IP and port, but also the node ID as third element of the array. In future versions there could be more elements describing the node better. In general a client implementation should just rely on the fact that certain parameters are at fixed positions as specified, but more parameters may follow and should be ignored. Similarly a client library should try if possible to cope with the fact that older versions may just have the IP and port parameter.

    *Return value

    Array reply: nested list of slot ranges with IP/Port mappings.

    *Sample Output (new version, includes IDs)

    1. 2) (integer) 5460
    2. 3) 1) "127.0.0.1"
    3. 2) (integer) 30001
    4. 3) "09dbe9720cda62f7865eabc5fd8857c5d2678366"
    5. 4) 1) "127.0.0.1"
    6. 2) (integer) 30004
    7. 2) 1) (integer) 5461
    8. 2) (integer) 10922
    9. 3) 1) "127.0.0.1"
    10. 2) (integer) 30002
    11. 4) 1) "127.0.0.1"
    12. 2) (integer) 30005
    13. 3) 1) (integer) 10923
    14. 2) (integer) 16383
    15. 3) 1) "127.0.0.1"
    16. 2) (integer) 30003
    17. 3) "044ec91f325b7595e76dbcb18cc688b6a5b434a1"
    18. 4) 1) "127.0.0.1"
    19. 2) (integer) 30006