首页 > 其他 > 详细

Redis之发布与订阅

时间:2019-09-04 22:24:53      阅读:66      评论:0      收藏:0      [点我收藏+]

发布订阅

  进程间的一种消息通信模式:发布者发送消息,订阅者接收消息

订阅者接收消息  一次性订阅多个

技术分享图片

 1 127.0.0.1:6379> SUBSCRIBE c1 c2 c3
 2 Reading messages... (press Ctrl-C to quit)
 3 1) "subscribe"
 4 2) "c1"
 5 3) (integer) 1
 6 1) "subscribe"
 7 2) "c2"
 8 3) (integer) 2
 9 1) "subscribe"
10 2) "c3"
11 3) (integer) 3
12 1) "message"
13 2) "c2"
14 3) "woshiniba"
15 1) "message"
16 2) "c1"
17 3) "woshinidie"
18 # -----------------------------通配符*-------------------
19 127.0.0.1:6379> PSUBSCRIBE new*
20 Reading messages... (press Ctrl-C to quit)
21 1) "psubscribe"
22 2) "new*"
23 3) (integer) 1
24 1) "pmessage"
25 2) "new*"
26 3) "new13"
27 4) "nishishabi"
28 
29 # 发布者发送消息
30 127.0.0.1:6379> PUBLISH c2 woshiniba
31 (integer) 1
32 127.0.0.1:6379> PUBLISH c1 woshinidie
33 (integer) 1
34 # -----------------------通配符--------------------------
35 127.0.0.1:6379> PUBLISH new13 nishishabi
36 (integer) 1

 相关指令https://www.runoob.com/redis/redis-pub-sub.html

Redis之发布与订阅

原文:https://www.cnblogs.com/Alexephor/p/11460988.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!