订阅端: Subscribe 频道名称
发布端: publish 频道名称 发布内容
实例:
服务端:
127.0.0.1:6379> publish zbbiex ‘hello word‘ (integer) 0 127.0.0.1:6379> publish zbbiex ‘hello word‘ (integer) 2
客户端1:
127.0.0.1:6379> subscribe zbbiex Reading messages... (press Ctrl-C to quit) 1) "subscribe" 2) "zbbiex" 3) (integer) 1 1) "message" 2) "zbbiex" 3) "hello word"
客户端2:
127.0.0.1:6379> subscribe zbbiex Reading messages... (press Ctrl-C to quit) 1) "subscribe" 2) "zbbiex" 3) (integer) 1 1) "message" 2) "zbbiex" 3) "hello word"
原文地址:https://www.cnblogs.com/zbbiex/p/10540475.html
时间: 2024-10-10 19:27:54