发布订阅
角色
发布者 publisher
订阅者 subscriber
频道 channel
模型
订阅者只会收到订阅频道的消息
一个订阅者可以订阅多个频道
频道所有的订阅者都可以收到消息
订阅者获取不到频道的历史消息
API
| api | 说明 |
|---|---|
| publish channel message | 发送消息到某个频道,返回的结果是该频道的订阅者数量 |
| subscribe [channel] | 订阅一个或多个频道 |
| unsubscribe [channel] | 取消订阅一个或多个频道 |
| psubscribe [pattern] | 按照模式订阅频道 |
| punsubscribe [pattern] | 按照模式取消订阅频道 |
| pubsub channels | 列出至少有一个订阅者的频道 |
| pubsub numbers [channel…] | 列出给定频道的订阅数量 |
| pubsub numpat | 列出被订阅模式的数量 |