redis消息订阅发布

1.登录redis

[root@es ~]# redis-cli
127.0.0.1:6379> 

2.认证

127.0.0.1:6379> AUTH xxxx
OK
127.0.0.1:6379> 

3.订阅1000这个消息

127.0.0.1:6379> SUBSCRIBE 1000
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "1000"
3) (integer) 1

4.给1000发送消息

127.0.0.1:6379> PUBLISH 1000 nihao
(integer) 1
127.0.0.1:6379> PUBLISH 1000 hahaha

原文地址:https://www.cnblogs.com/setout/p/11548186.html