helowken 2019-06-27
SUBSCRIBE channel [channel channel ...]
$ redis-cli # 进程1 127.0.0.1:6379> SUBSCRIBE chat chat2 Reading messages... (press Ctrl-C to quit) 1) "subscribe" 2) "chat" 3) (integer) 1 1) "subscribe" 2) "chat2" 3) (integer) 2
PUBLISH channel message
$ redis-cli # 进程2 127.0.0.1:6379> PUBLISH chat hellochat1 (integer) 1 127.0.0.1:6379> PUBLISH chat2 hellochat2 (integer) 1 #此时的进程1 127.0.0.1:6379> SUBSCRIBE chat chat2 Reading messages... (press Ctrl-C to quit) 1) "subscribe" 2) "chat" 3) (integer) 1 1) "subscribe" 2) "chat2" 3) (integer) 2 1) "message" 2) "chat" 3) "hellochat1" 1) "message" 2) "chat2" 3) "hellochat2"