CLUSTER KEYSLOT
CLUSTER KEYSLOT key
- Group
- Cluster
- Complexity
- O(N) where N is the length of the key
- Arity
- 3 (exactly, counting the command name)
- HotKV Cloud
- All plans
- On-Premise
- no license needed
CLUSTER KEYSLOT returns the hash slot (0 to 16383) of a key name, computed
with the standard CRC16 cluster hash. If the key contains a hash tag, a
non-empty part between the first { and the next }, only that part is
hashed, so user:1000 and {user:1000}:cart share a slot.
The key does not need to exist. The command works with cluster mode off too, which is handy for checking how keys would be distributed.
Return value
Section titled “Return value”Integer in RESP2 and RESP3: the slot.
Examples
Section titled “Examples”127.0.0.1:6379> CLUSTER KEYSLOT order:77(integer) 9221127.0.0.1:6379> CLUSTER KEYSLOT {user:1000}:cart(integer) 1649127.0.0.1:6379> CLUSTER KEYSLOT user:1000(integer) 1649Compatibility
Section titled “Compatibility”Same slot function and replies as Redis 7 and Valkey 8, so a client that computes slots itself agrees with HotKV.
See also
Section titled “See also”CLUSTER COUNTKEYSINSLOT, CLUSTER SLOTS, Clustering: Slots and redirects
Was this page helpful?
Thanks for the feedback.