CLUSTER GETKEYSINSLOT
CLUSTER GETKEYSINSLOT slot count
- Group
- Cluster
- Complexity
- O(N) where N is the number of keys in the slot
- Arity
- 4 (exactly, counting the command name)
- HotKV Cloud
- All plans
- On-Premise
- no license needed
CLUSTER GETKEYSINSLOT returns up to count key names that the receiving
node holds in the given hash slot. Resharding tools call it in a loop on the
source node: fetch a batch of keys, move them with
MIGRATE, and repeat until the reply is empty.
Keys whose time to live has run out are left out. The keys are those of the
selected database: a cluster node has one database unless cluster-databases
is above 1, and then the command lists the keys of the database the connection
has selected. With cluster mode off the reply is always an empty array.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Valid arguments | Array of bulk strings (empty when the slot has no keys or count is 0) |
Array |
slot or count not an integer |
Error ERR value is not an integer or out of range |
Same error |
Slot not from 0 to 16383, or a negative count |
Error ERR Invalid slot or number of keys |
Same error |
The order of the keys is not defined.
Examples
Section titled “Examples”127.0.0.1:6379> CLUSTER GETKEYSINSLOT 1649 101) "user:1000"2) "{user:1000}:cart"3) "{user:1000}:sessions"127.0.0.1:6379> CLUSTER GETKEYSINSLOT 1649 -1(error) ERR Invalid slot or number of keysCompatibility
Section titled “Compatibility”Same replies and error strings as Redis 7 and Valkey 8.
See also
Section titled “See also”CLUSTER COUNTKEYSINSLOT, MIGRATE, CLUSTER SETSLOT
In a cluster: Scaling a cluster
Was this page helpful?
Thanks for the feedback.