本文内容为 http://www.redis.io/commands/subscribe 的翻译、注解、例子扩充及其它修改。感谢 Redis 作者 Antirez 为开源社区作出的贡献,本文保证最新、最准、最全以表示对其的敬意。欢迎留言纠错、提示更新或支持。
SUBSCRIBE channel [channel ...]

订阅(Subscribe)客户端(Client)程序到指定到的频道(Channel)

Subscribes the client to the specified channels.

一旦客户端进入订阅模式,除了命令 SUBSCRIBEPSUBSCRIBEUNSUBSCRIBEPUNSUBSCRIBE 以外,不应该执行其它任何命令。

Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE and PUNSUBSCRIBE commands.
  • 版本支持

    2.0.0+

    时间复杂度(Time complexity)

    O(N)N 为订阅的频道数。

    O(N) where N is the number of channels to subscribe to.