PUBSUB-SHARDNUMSUB(3valkey)
π PUBSUB-SHARDNUMSUB π
okay bestie, welcome to the Valkey Command Manual entry for pubsub-shardnumsub β yes it's a mouthful, no you're not gonna say it out loud, just trust me π«Ά
β¨ NAME β¨
pubsub-shardnumsub β literally just returns the count of subscribers of shard channels. that's the whole job. she's got one task and she ate π
πΈ SYNOPSIS πΈ
PUBSUB SHARDNUMSUB shardchannel [shardchannel...]
π¦ DESCRIPTION π¦
So here's the tea: this one gives you back the number of subscribers for the shard channels you name. one channel, five channels, whatever β you ask, it counts. β¨
And lowkey the most important thing: it is totally valid to call this command with no channels at all. no channels? no problem. it'll just return an empty list. iconic behaviour honestly.
Cluster note (read this one fr fr): in a Valkey Cluster, the replies fromvalkey-pubsub(7)PUBSUBin a cluster only report information from the node's own Pub/Sub context β not the entire cluster. so don't come for the numbers like they're the whole picture, bestie, they're not. π
π REPLY π
valkey-protocol(7) Array reply: the number of subscribers per shard channel. and here's the pattern you gotta memorise:
- every even element (including the
0th) is the channel name π - every odd element is the number of subscribers π
so it's name, count, name, count, name, count... you get it. it's giving choreography. π
π₯ COMPLEXITY π₯
O(N) for the SHARDNUMSUB subcommand, where N is the number of requested shard channels. yes queen, linear, slay. β
π ACL CATEGORIES π
@pubsub@slow
(iykyk which keys you need π)
π HISTORY π
- Available since:
7.0.0β she's not new new, but she's not ancient either. a respectable era. π«
π EXAMPLES π
okay watch this, one channel called orders, and:
> PUBSUB SHARDNUMSUB orders
1) "orders"
2) (integer) 1
so "orders" is element zero (the channel name, as promised) and (integer) 1 is the subscriber count. one whole subscriber out here holding it down. periodt. π
π§ SEE ALSO π§
psubscribe(3valkey)publish(3valkey)pubsub(3valkey)pubsub-channels(3valkey)pubsub-help(3valkey)pubsub-numpat(3valkey)pubsub-numsub(3valkey)pubsub-shardchannels(3valkey)punsubscribe(3valkey)spublish(3valkey)ssubscribe(3valkey)subscribe(3valkey)sunsubscribe(3valkey)unsubscribe(3valkey)
and that's the whole page, bestie!! π«Ά this one's from version 9.0.0, dated 2025-10-21, and it's the PUBSUB-SHARDNUMSUB(3valkey) entry in the Valkey Command Manual. go forth and count your subscribers. mwah ππ
π¦ 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