1、 消息订阅
2、消息推送
相关命令
发布消息:
这个一定要先订阅频道,才能发布消息,不然消息会出现错误。
#消息未发布成功
127.0.0.1:6379> PUBLISH new1 hhhh
(integer) 0
# 先subscribe 频道,才能发布消息
[root@hadoop03 bin]# ./redis-cli
127.0.0.1:6379> PUBLISH new1 hehello
(integer) 1
127.0.0.1:6379>
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "new1"
3) (integer) 1
1) "message"
2) "new1"
3) "hehello"
---取消订阅
127.0.0.1:6379> UNSUBSCRIBE new1
1) "unsubscribe"
2) "new1"
3) (integer) 0