Redis 订阅分为频道和模式,每个Redis 客户端可以订阅多个频道或者模式。发布消息时,先查询pubsub_channels 中的字典,将消息发送给字典下的client 链表,然后开始在pubsub_patterns 链表中查找是否有被订阅的模式相匹配的
一个pubsub_channels 字典
pubsub_patterns 链表事例
订阅channel
subscribe news.it
subscribe news.it news.sport
退订channel
unsubscribe news.it
订阅模式
psubscribe news.*
退订模式
punsubscribe news.*
发送消息
publish news.it "hello"'