Tair and Tair cluster instances restrict commands that span multiple hash slots — a single command cannot operate on keys that belong to different slots. Before running such a command, use CLUSTER KEYSLOT to confirm which slot a key belongs to.
For cluster instances in proxy mode, INFO KEY returns both the slot number and the data node index in one call.
Prerequisites
Before you begin, ensure that you have:
A Tair or Tair cluster instance
A client connected to the instance (for example, redis-cli). See Use redis-cli to connect to an instance
Query the slot of a key
Run the following command to get the hash slot for a key:
CLUSTER KEYSLOT <key>Example: Query the slot for the key foo:
CLUSTER KEYSLOT fooExpected output:
12182Query the data node and slot (proxy mode only)
For cluster instances in proxy mode, use the INFO KEY command to get both the slot and the data node index:
INFO KEY <key>Example: Query the slot and data node for the key foo:
INFO KEY fooExpected output:
slot:12182 node_index:2INFO KEY is developed in-house by the Alibaba Cloud Tair team and is supported only for cluster instances in proxy mode.
What's next
To learn all commands available for proxy mode instances, see In-house commands for instances in proxy mode.
For commands that work across slots in proxy mode — such as
DELandEXISTS— see Limits on commands supported by cluster instances and read/write splitting instances.