CLUSTER...YSINSLOT(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’– 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:


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