Redis (7): suscripción y publicación de noticias

suscripción

Suscriptor 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

Suscriptor 2:

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

Publicar mensaje en la canalización 1:

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

Suscripción 1 y Suscripción 2 reciben mensajes:

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

 

Supongo que te gusta

Origin blog.csdn.net/qq_22420441/article/details/87537184
Recomendado
Clasificación