• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
MC_Hotdog
Yeah, you're right I'm still riding that crappy bike
博客园    首页    新随笔    联系   管理    订阅  订阅

Redis之发布与订阅

发布订阅

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

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

 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

posted @ 2019-09-04 21:03  MC_Hotdog  阅读(255)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3