CLUSTER...YSINSLOT(3valkey)
π CLUSTER COUNTKEYSINSLOT π
okay bestie, welcome to the Valkey Command Manual β¨ we're doing cluster-countkeysinslot today and honestly? it's giving "quick little count, no drama." let's go π«Ά
πΈ NAME πΈ
cluster-countkeysinslot β returns the number of keys in a hash slot. that's it. that's the whole job. π
π SYNOPSIS π
CLUSTER COUNTKEYSINSLOT slot
β¨ DESCRIPTION β¨
so basically, this one tells you how many keys are chilling in the specified Valkey Cluster hash slot, and it's counting them in the currently selected database only. not all of them, not the whole cluster β just here. π
and here's the tea, bestie: it only queries the local data set. so if you go bother a node that isn't actually serving the hash slot you asked about? you're getting a count of zero. every single time. no cap. it's not being shady, it just genuinely doesn't have those keys. π
like, watch:
> CLUSTER COUNTKEYSINSLOT 7000
(integer) 50341
look at that. 50341 keys. iconic. π
π₯ REPLY π₯
valkey-protocol(7) Integer reply: the number of keys in the specified hash slot, or an error if the hash slot is invalid. so yeah, bad slot = error, no key count for you π
β COMPLEXITY β
O(1) β constant time, baby. it does not care how big anything is. main character energy fr fr. π«
π ACL CATEGORIES π
@slow
π¦ HISTORY π¦
- Available since: 3.0.0 β a certified classic, been here forever π
π SEE ALSO π
go read these too, they're all part of the cluster fam:
asking(3valkey)cluster(3valkey)cluster-addslots(3valkey)cluster-addslotsrange(3valkey)cluster-bumpepoch(3valkey)cluster-cancelslotmigrations(3valkey)cluster-count-failure-reports(3valkey)cluster-delslots(3valkey)cluster-delslotsrange(3valkey)cluster-failover(3valkey)cluster-flushslots(3valkey)cluster-forget(3valkey)cluster-getkeysinslot(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)
and that's the whole page, bestie!! π this was Valkey 9.0.0, dated 2025-10-21, and it lives in the Valkey Command Manual. slay, go count some keys, ily π«Άπβ¨
π¦ 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