Redis-消息发布与订阅
2016-10-13 22:22
288 查看
redis的消息发布与订阅适合做在线聊天, 消息推送
使用方法:发布端: publish +频道名称 + 发布内容
订阅端: subscribe + 频道名称
发布端例子:
127.0.0.1:6379> publish news 'this is a test' (integer) 0 127.0.0.1:6379>
新开一个redis-cli
订阅端:
127.0.0.1:6379> subscribe news Reading messages... (press Ctrl-C to quit) 1) "subscribe" 2) "news" 3) (integer) 1
再次在发布端发布一个消息
127.0.0.1:6379> publish news 'another test' (integer) 1 #返回的数字表示目前订阅这个频道的数量 127.0.0.1:6379>
查看订阅端
127.0.0.1:6379> subscribe news Reading messages... (press Ctrl-C to quit) 1) "subscribe" 2) "news" 3) (integer) 1
1) "message"
2) "news"
3) "another test"
psubscribe
模糊订阅, 比如订阅上例的news, 可以写成 __psubscribe ne*__ , 表示订阅所有 ne 开头的频道相关文章推荐
- Redis消息系统——发布/订阅
- 发布与订阅消息--Redis学习笔记八
- Spring MVC + redis 消息的订阅发布
- php 实现redis发布订阅消息及时通讯
- redis实现消息队列&发布/订阅模式使用
- Redis的消息订阅与发布
- redis发布与订阅消息
- Redis消息的发布/订阅
- 使用redis的发布订阅模式实现消息队列
- Java实现Redis的消息订阅和发布
- Redis高级实用特性(持久化机制、发布订阅消息、虚拟内存的使用)
- Redis实现消息的发布/订阅
- redis订阅发布消息操作本地缓存
- redis 消息订阅 发布
- redis-消息订阅与发布
- Redis pub/sub机制在实际运用场景的缺陷&&模拟JMS消息发布订阅的持久化特性
- Java实现Redis的消息订阅和发布
- redis 高级应用之二(Redis的持久化 和 消息的[pub/sub]发布和订阅)
- 使用Spring-Redis实现消息的发布/订阅
- Redis消息通知(任务队列和发布订阅模式)