redis做消息推送的示例:
客户端A订阅通道:
redis 127.0.0.1:6379> SUBSCRIBE channeltest
客户端B往该通道发送消息:
redis 127.0.0.1:6379> PUBLISH channeltest hello(integer) 1
redis 127.0.0.1:6379> PUBLISH channeltest world
(integer) 1
客户端A就能获取到推送的信息:
redis 127.0.0.1:6379> SUBSCRIBE channeltestReading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "channeltest"
3) (integer) 1
1) "message"
2) "channeltest"
3) "hello"
1) "message"
2) "channeltest"
3) "world"