PUBSUB
Since 1.1.0Pub/Sub
Syntax
PUBSUBPUBSUB is a container: its subcommands report on the channels and patterns clients are subscribed to. They do not subscribe or publish anything, and they count only the clients connected to the server that answers; in a cluster, each node reports its own.
| Subcommand | |
|---|---|
PUBSUB CHANNELS | the channels with subscribers, optionally those matching a pattern |
PUBSUB NUMSUB | how many clients are subscribed to each of some channels |
PUBSUB NUMPAT | how many distinct patterns are subscribed to |
PUBSUB SHARDCHANNELS, PUBSUB SHARDNUMSUB | the same for shard channels |
PUBSUB HELP | the list, from the server |
Pub/Sub explains channels, patterns, shard channels and delivery. PUBSUB alone, or with a name that is not a subcommand, is an error.
Examples
> PUBSUB
(error) ERR wrong number of arguments for 'pubsub' command
> PUBSUB NOPE
(error) ERR unknown PUBSUB subcommand 'NOPE'
With one client subscribed to news:
> PUBSUB NUMSUB news
1) "news"
2) (integer) 1
Subcommands
- PUBSUB CHANNELS: Returns the channels that at least one client is subscribed to with SUBSCRIBE, sorted.
- PUBSUB HELP: Lists the PUBSUB subcommands, one line each with its arguments, followed by an indented line saying what it does: CHANNELS, NUMPAT, NUMSUB, SHARDCHANNELS, SHARDNUMSUB and HELP.
- PUBSUB NUMPAT: Returns how many distinct patterns clients are subscribed to with PSUBSCRIBE.
- PUBSUB NUMSUB: Returns, for each channel named, how many clients are subscribed to it with SUBSCRIBE.
- PUBSUB SHARDCHANNELS: Returns the shard channels that at least one client is subscribed to with SSUBSCRIBE, sorted.
- PUBSUB SHARDNUMSUB: Returns, for each shard channel named, how many clients are subscribed to it with SSUBSCRIBE.