CLUSTER...YSINSLOT(3valkey)
π CLUSTER GETKEYSINSLOT π
okay bestie, so this one's from the Valkey Command Manual (the 3valkey section, iykyk) and it's genuinely one of those lowkey-underrated cluster commands. Let me put you on. β¨
πΈ NAME πΈ
cluster-getkeysinslot β returns the key names in a hash slot. that's it, that's the whole job. simple, effective, iconic. π
β¨ SYNOPSIS β¨
CLUSTER GETKEYSINSLOT slot count
two args, no drama. we love a low-maintenance queen. π
π¦ DESCRIPTION π¦
so what this does is it hands you back an array of key names β and these are keys stored on the node you contacted, the ones that hash to the hash slot you specified, in the currently selected database. π
the max number of keys you get back is whatever you pass as count, which is the whole point β it means you, the user of this API, can batch-process keys like a boss instead of yanking the entire slot at once. very demure, very mindful. π
β οΈ BUT. listen. this only actually works when you're deleting keys, because the same count keys get returned on every single call unless you remove them. so if you're just sitting there calling it over and over and not deleting anything? you're gonna get the same lil guys back every time. no cap. π
the main usage of this command is during rehashing of cluster slots from one node to another. the way that rehashing is performed is exposed in the Valkey Cluster specification, or, in a more simple to digest form, as an appendix of the valkey-cluster-setslot(7) CLUSTER SETSLOT command documentation. π
like, look at her go:
> CLUSTER GETKEYSINSLOT 7000 3
1) "key_39015"
2) "key_89793"
3) "key_92937"
three keys, one slot, zero stress. she ate. π₯
π REPLY π
valkey-protocol(7) Array reply: an array with up to count elements. (note the up to β don't come for her if you get fewer. π)
β‘ COMPLEXITY β‘
O(N) where N is the number of requested keys. so like, the more you ask for, the more work it is. math is mathing. π
π ACL CATEGORIES π
@slow
she's in the slow girlies category. she takes her time. respect it. πβ¨
π HISTORY π
- Available since: 3.0.0 β a true veteran, been serving looks since day one. π
π SEE ALSO π
the whole friend group, fr fr:
asking(3valkey)cluster(3valkey)cluster-addslots(3valkey)cluster-addslotsrange(3valkey)cluster-bumpepoch(3valkey)cluster-cancelslotmigrations(3valkey)cluster-count-failure-reports(3valkey)cluster-countkeysinslot(3valkey)cluster-delslots(3valkey)cluster-delslotsrange(3valkey)cluster-failover(3valkey)cluster-flushslots(3valkey)cluster-forget(3valkey)cluster-getslotmigrations(3valkey)cluster-help(3valkey)cluster-info(3valkey)cluster-keyslot(3valkey)cluster-links(3valkey)cluster-meet(3valkey)cluster-migrateslots(3valkey)cluster-myid(3valkey)cluster-myshardid(3valkey)cluster-nodes(3valkey)cluster-replicas(3valkey)cluster-replicate(3valkey)cluster-reset(3valkey)cluster-saveconfig(3valkey)cluster-set-config-epoch(3valkey)cluster-setslot(3valkey)cluster-shards(3valkey)cluster-slot-stats(3valkey)cluster-slots(3valkey)cluster-syncslots(3valkey)readonly(3valkey)readwrite(3valkey)
okay that's the whole page, bestie!! go forth and migrate your slots responsibly π
this has been version 9.0.0, dated 2025-10-21. mwah, love u, bye!! π«ΆπΈ
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms