What's new in Valkey 9.0? Discover new features and improvements. Read the announcement.

PUBSUB NUMPAT

Returns a count of unique pattern subscriptions.

Usage
PUBSUB NUMPAT
Complexity
O(1)
Since
2.8.0
ACL Categories
@pubsub, @slow
Command flags
PUBSUB, LOADING, STALE

Returns the number of unique patterns that are subscribed to by clients (that are performed using the PSUBSCRIBE command).

Note that this isn't the count of clients subscribed to patterns, but the total number of unique patterns all the clients are subscribed to.

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, the replies from PUBSUB in a cluster only report information from the node's Pub/Sub context, rather than the entire cluster.

Replies

RESP2

Integer reply: the number of patterns all the clients are subscribed to.

RESP3

Integer reply: the number of patterns all the clients are subscribed to.