PUBSUB
PUBSUB CHANNELS [pattern] PUBSUB NUMSUB [channel [channel ...]] PUBSUB NUMPAT PUBSUB SHARDCHANNELS [pattern] PUBSUB SHARDNUMSUB [shardchannel [shardchannel ...]] PUBSUB HELP
- Group
- Pub/Sub
- Arity
- -2 (at least 2 words, counting the command name)
- Flags
- pubsub, read-only
- HotKV Cloud
- All plans
- On-Premise
- no license needed
PUBSUB is a container for subcommands that report on Pub/Sub activity on the
node you ask. They only read state and never deliver messages.
| Subcommand | What it returns |
|---|---|
| PUBSUB CHANNELS | Channels with at least one subscriber |
| PUBSUB NUMSUB | The subscriber count of each named channel |
| PUBSUB NUMPAT | The number of pattern subscriptions |
| PUBSUB SHARDCHANNELS | Shard channels with at least one subscriber |
| PUBSUB SHARDNUMSUB | The subscriber count of each named shard channel |
PUBSUB HELP |
A short description of each subcommand |
An unknown subcommand replies with
ERR unknown subcommand '<name>'. Try PUBSUB HELP.
Examples
Section titled “Examples”127.0.0.1:6379> PUBSUB CHANNELS1) "news"127.0.0.1:6379> PUBSUB NUMSUB news1) "news"2) (integer) 2Compatibility
Section titled “Compatibility”The same subcommands as Redis 7 and Valkey 8. See PUBSUB NUMPAT for one difference in what it counts.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.