订阅

Syntax
SUBSCRIBE channel [channel ...]
Available since:
2.0.0
Time complexity:
O(N) where N is the number of channels to subscribe to.
ACL categories:
@pubsub, @slow,

订阅客户端到指定的频道。

一旦客户端进入订阅状态,除了额外的SUBSCRIBESSUBSCRIBEPSUBSCRIBEUNSUBSCRIBESUNSUBSCRIBEPUNSUBSCRIBEPINGRESETQUIT命令外,不应该发出任何其他命令。然而,如果使用RESP3(参见HELLO),客户端在订阅状态下可以发出任何命令。

欲了解更多信息,请参阅Pub/sub

行为变更历史

  • >= 6.2.0: RESET 可以被调用来退出订阅状态。

RESP2/RESP3 回复

When successful, this command doesn't return anything. Instead, for each channel, one message with the first element being the string subscribe is pushed as a confirmation that the command succeeded.
RATE THIS PAGE
Back to top ↑