redis-消息订阅

时间:2023-12-05 16:30:14

使用办法:

订阅端: Subscribe 频道名称

发布端: publish 频道名称发布内容

客户端例子:

redis 127.0.0.1:> subscribe news

Reading messages... (press Ctrl-C to quit)
) "subscribe"
) "news"
) (integer)
) "message"
) "news"
) "good good study"
) "message"
) "news"
) "day day up"

服务端例子:

redis 127.0.0.1:> publish news 'good good study'
(integer)
redis 127.0.0.1:> publish news 'day day up'
(integer)