修改本页

Redis 命令 客户端 文档 社区 下载 问题 支持 许可

PUBSUB subcommand [argument [argument …]]

Related topics

相关命令

Available since 2.8.0.

时间复杂度: O(N) for the CHANNELS subcommand, where N is the number of active channels, and assuming constant time pattern matching (relatively short channels and patterns). O(N) for the NUMSUB subcommand, where N is the number of requested channels. O(1) for the NUMPAT subcommand.

The PUBSUB command is an introspection command that allows to inspect the state of the Pub/Sub subsystem. It is composed of subcommands that are documented separately. The general form is:

  1. PUBSUB <subcommand> ... args ...

PUBSUB CHANNELS [pattern]

Lists the currently active channels. An active channel is a Pub/Sub channel with one ore more subscribers (not including clients subscribed to patterns).

If no pattern is specified, all the channels are listed, otherwise if pattern is specified only channels matching the specified glob-style pattern are listed.

返回值

Array reply: a list of active channels, optionally matching the specified pattern.

PUBSUB NUMSUB [channel-1 … channel-N]

Returns the number of subscribers (not counting clients subscribed to patterns) for the specified channels.

返回值

Array reply: a list of channels and number of subscribers for every channel. The format is channel, count, channel, count, …, so the list is flat. The order in which the channels are listed is the same as the order of the channels specified in the command call.

Note that it is valid to call this command without channels. In this case it will just return an empty list.

PUBSUB NUMPAT

Returns the number of subscriptions to patterns (that are performed using the PSUBSCRIBE command). Note that this is not just the count of clients subscribed to patterns but the total number of patterns all the clients are subscribed to.

返回值

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

Comments powered by Disqus

This website is open source software developed by Citrusbyte.

The Redis logo was designed by Carlos Prioglio. See more credits.

Sponsored by Redis Support