弄技术要弄通-公司reis的pub/sub怎么使用的呢?
2018-01-31 23:44
465 查看
Pub/Sub in Redis using PHP
Posted on November 14, 2011by xmengI would like to put an example together about the pub/sub using php in Redis; there is only API documentation available in phpredis, the PHP client I am using (http://redis.io/clients).
0. Setup
First setup a Redis Server. I set up a Redis server in my local box using port 6378 (myredisserver.test.com:6378).
1. Publish: push a message to a channel.
This part is relatively easy. The following is a php script “publish.php“.
Let’s take a break now and see what will happen if we run the script “publish.php” from a client side.
Because I use a non default port, “-p” option is used with “redis-cli” command.
Open a new terminal at Redis Server, and issue “MONITOR” command in redis “console”:
Here is the complete php script “subscribe.php” after I did some debugging. Thanks to the info here: https://github.com/nicolasff/phpredis/issues/36.
1) run script “subscribe.php“:
2) In another terminal window, run script “publish.php” twice, and come back to have a look!
Reference: http://robots.thoughtbot.com/post/6325247416/redis-pub-sub-how-does-it-work
相关文章推荐
- 公司怎么吸引和留住核心技术大牛
- php redis pub/sub(Publish/Subscribe,发布/订阅的信息系统)之基本使用
- 10个窍门:怎么使用公司禁用软件?
- 怎么做好互联网公司的技术团队负责人?
- 从技术人员的角度看,公司怎么生存?
- 准备些一篇目前技术目前公司 使用技术的 解析
- 怎么做好互联网公司的技术团队负责人?
- 阿里云和Docker秀恩爱?容器技术公司怎么看?
- linux下使用hiredis异步API实现sub/pub消息订阅和发布的功能
- ActiveMq--Pub/Sub的使用
- 全景VR视频游戏外包公司:技术分享使用U3D+CB制作VR游戏
- 当cookie禁用时怎么使用session技术--URL重写技术
- 实验:基本的系统安全控制 实验环境 某公司新增了一台企业级服务器,已安装运行RHEL 6操作系统,由系统运维部、软件开发部、技术服务部共同使用。由于用户数量众多,且使用时间不固定,要求针对账号和
- 各大互联网公司技术总监分享:前端程序员怎么拿到30K以上月薪!
- 轻舟已过万重山——真正的技术派公司是怎么联调、测试和发布的?
- 使用Service.Stack客户端编写redis pub sub的方法
- 总结一下公司项目使用各种较新的前端技术和 Api 的一些经验。
- 去年5月份,公司项目较少,我就组织了一个用于公司内部办公管理的项目(以下称OA)。第一个目的是为了让公司里面一些技术较差的人员得到真正编程的锻炼;第二个目的是为了使用空闲的人员为公司开发一个产品,在内
- 使用SQL SERVER / SSB 实现Pub/Sub集成模式