Redis的发布订阅模式
Redis的发布订阅模式:
发送者发送消息,订阅者接收消息,Redis 客户端可以订阅任意数量的频道。
相关命令:
-
psubscribe pattern [pattern …]
订阅一个或多个符合给定模式的频道 -
pubsub subcommand [argument [argument …]]
查看订阅与发布系统状态 -
publish channel message
将信息发送到指定的频道 -
punsubscribe [pattern [pattern …]]
退订所有给定模式的频道 -
subscribe channel [channel …]
订阅给定的一个或多个频道的信息 -
unsubscribe [channel [channel …]]
指退订给定的频道
例:
订阅“redisChat”测试频道
发送消息到指定频道
查看结果