Redis (7): News Subscription and Publishing

subscription

Subscriber 1:

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

Subscriber 2:

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

Publish message to pipeline 1:

127.0.0.1:6379> PUBLISH channel1 "this is a msg"
(integer) 2
# 2表示2个订阅方已接受

Subscription 1 and Subscription 2 receive messages:

1) "message"
2) "channel1"
3) "this is a msg"

 

Guess you like

Origin blog.csdn.net/qq_22420441/article/details/87537184