简介 进程间的消息通信模式: 发送者(pub)发送消息,订阅者(sub)接收消息 示例,订阅多个 127.0.0.1:8686[1]> SUBSCRIBE c1 c2 c3 Reading messages... (press C
进程间的消息通信模式: 发送者(pub)发送消息,订阅者(sub)接收消息
127.0.0.1:8686[1]> SUBSCRIBE c1 c2 c3
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "c1"
3) (integer) 1
1) "subscribe"
2) "c2"
3) (integer) 2
1) "subscribe"
2) "c3"
3) (integer) 3
# 另外一个客户端通过c1频道发送消息
remoteSelf:1> publish c1 "hello c1"
"1"
1) "message"
2) "c1"
3) "hello c1"
[root@izm5e2q95pbpe1hh0kkwoiz ~]# redis-cli -p 8686
127.0.0.1:8686> auth ****(密码)
OK
127.0.0.1:8686> select 1
OK
127.0.0.1:8686[1]> PSUBSCRIBE new*
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "new*"
3) (integer) 1
# 发送订阅信息
remoteSelf:1>publish new1 "hello new1"
"1"
1) "pmessage"
2) "new*"
3) "new1"
4)
--结束END--
本文标题: redis的发布订阅
本文链接: https://www.lsjlt.com/news/4196.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0