Redis基础系列-0x008:发布订阅模式
0x001 订阅一个或者多个频道
命令格式: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
0x002 发布消息
命令格式: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"
相关推荐
chenshengzun 2015-03-26
tuxlcsdn 2019-06-28
zhaow 2009-04-15
琳 2015-03-24
wulantian 2016-08-29
wyx 2015-04-25
RyanB 2012-10-04
CXPOwen 2012-03-13
lispython 2019-02-21
ytruytutyututyut 2011-09-24