ads:
关注以下公众号查看更多文章
redis channel命令组提供了发布、订阅(oub/sub)模式的支持
订阅频道
psubscribe news wealther
发布频道消息
publish news "方海亮是帅哥"
publish wealther "天气晴朗"
订阅频道者收到的消息如下
- 127.0.0.1:6379> psubscribe news wealther
- Reading messages... (press Ctrl-C to quit)
- 1) "psubscribe"
- 2) "news"
- 3) (integer) 1
- 1) "psubscribe"
- 2) "wealther"
- 3) (integer) 2
-
-
-
- 1) "pmessage"
- 2) "news"
- 3) "news"
- 4) "aaaaaa"
-
-
- 1) "pmessage"
- 2) "wealther"
- 3) "wealther"
- 4) "bbbbbb"