Returns a count of subscribers to channels.
PUBSUB
NUMSUB
channel
[channel…]
Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
Note that it is valid to call this command without channels. In this case it will just return an empty list.
Cluster note: in a Valkey Cluster clients can subscribe to every
node, and can also publish to every other node. The cluster will make
sure that published messages are forwarded as needed. That said,
PUBSUB
’s replies in a cluster only report information from
the node’s Pub/Sub context, rather than the entire cluster.
Array reply: the number of subscribers per channel, each even element (including the 0th) is channel name, each odd element is the number of subscribers
O(N) for the NUMSUB subcommand, where N is the number of requested channels
@pubsub @slow
PSUBSCRIBE, PUBLISH, PUBSUB, PUBSUB CHANNELS, PUBSUB HELP, PUBSUB NUMPAT, PUBSUB SHARDCHANNELS, PUBSUB SHARDNUMSUB, PUNSUBSCRIBE, SPUBLISH, SSUBSCRIBE, SUBSCRIBE, SUNSUBSCRIBE, UNSUBSCRIBE.