redis之发布订阅

Redis 发布订阅(pub/sub)是一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息。
Redis 客户端可以订阅任意数量的频道。
下图展示了频道 channel1 , 以及订阅这个频道的三个客户端 —— client2 、 client5 和 client1 之间的关系:


示例:


其他
psubscribe pattern [pattern ...]  
订阅一个或多个符合给定模式的频道。

pubsub subcommand [argument [argument ...]] 
查看订阅与发布系统状态。

publish channel message 
将信息发送到指定的频道。

PUNSUBSCRIBE [pattern [pattern ...]]
退订所有给定模式的频道。

SUBSCRIBE channel [channel ...]
订阅给定的一个或多个频道的信息。

UNSUBSCRIBE [channel [channel ...]]
指退订给定的频道。

猜你喜欢

转载自zhaoxiaoboblogs.iteye.com/blog/2310419