redis 发布与订阅
首页->学习资料->微服务治理->redis 关键词: 发布时间:2018-06-14 14:28:59 浏览次数:1471

【redis 发布与订阅】

有点类似于长连接,发布者发布消息,所有订阅此频道的都会收到消息,但是后来加进来的订阅者是收不到之前发布的消息的;

不同于消息队列,消息队列有点像靠抢,谁先拿到,其它的就拿不到同一个任务了;

发布:publissh

订阅:subscribe

取消订阅:unsubcribe

订阅模式:psubscribe

退订指定的模式:punsubscribe

列出至少有一个订阅者的频道:pubsub channels

列出给定频道的订阅者数量:pubsub numsub

列出被订阅模式的数量:pubsub numpat

模拟发布者:

127.0.0.1:6379> publish testchannel 'this is from publish'

(integer) 2

模拟订阅者1:

127.0.0.1:6379> subscribe testchannel

Reading messages... (press Ctrl-C to quit)

1) "subscribe"

2) "testchannel"

3) (integer) 1

1) "message"

2) "testchannel"

3) "this is from publish"

模拟订阅者2:

127.0.0.1:6379> subscribe testchannel

Reading messages... (press Ctrl-C to quit)

1) "subscribe"

2) "testchannel"

3) (integer) 1

1) "message"

2) "testchannel"

3) "this is from publish"


赞:(0)
踩:(0)
相关文章
redis数据持久化
memcache与redis比较
redis数据类型及常用命令
redis慢查询
redis pipeline
redis位图bitmap
redis HyperLogLog
redis geo
redis布隆过滤器
redis消息队列实例
热门文章
win7中将文件拷贝到虚拟机linux下
phpexcel设置行高及列宽,背景颜色,
rabbitmq无法启动
intellij idea不显示git push按钮
php7中使用mongodb的aggregate进行
centos7.4 64位下swoole安装及配置
laravel页面静态化的方法
navicate连接mycat报1184错误
单点登录sso原理及php实现方式及de
devops-jenkins容器为pending状态
好评文章
phpexcel设置行高及列宽,背景颜色,
php7中使用mongodb的aggregate进行
intellij idea打开文件所在文件夹
windows下使用MongoDB Compass Com
win7中将文件拷贝到虚拟机linux下
laravel 中悲观锁 & 乐观锁的使用
单点登录sso原理及php实现方式及de
navicate连接mycat报1184错误
rabbitmq无法启动
laravel整合dingo/api方法步骤:jwt
标签
rabbitmq mysql备份 elasticsearch golang swoole
我的项目
【github】www.github.com/hurong241
【码云】gitee.com/hu_rong/projects
【docker hub】hub.docker.com/repositories/hurong241
【packagist】packagist.org/users/hurong241/packages
站点信息
建站时间:2011年
文章数:607篇
浏览数:940840
粤ICP备18028092号-1  微信:hurong241