Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

PUBSUB NUMPAT

Last updated
PUBSUB NUMPAT
Group
Pub/Sub
Complexity
O(N) where N is the number of subscribed patterns
Arity
2 (exactly, counting the command name)
HotKV Cloud
All plans
On-Premise
no license needed

PUBSUB NUMPAT returns how many pattern subscriptions, made with PSUBSCRIBE, exist on this node. Each connection’s subscription counts: two connections subscribed to the same pattern count as two.

Case RESP2 RESP3
Always Integer Integer

With one connection subscribed to news.* and another to news.* and alerts.*:

127.0.0.1:6379> PUBSUB NUMPAT
(integer) 3

Redis 7 and Valkey 8 count distinct patterns instead, so in the example above they would reply 2. The reply is the same when no pattern is shared between connections.

PSUBSCRIBE, PUBSUB, PUBSUB NUMSUB