Redis的发布订阅

Posted by Chenyawei on 2020-01-21
Words 103 and Reading Time 1 Minutes
Viewed Times

1、什么是发布订阅

进程间的一种消息通信模式:发送者(pub)发送消息,订阅者(sub)接收消息。

订阅/发布消息图:

img

2、命令

img

3、案列

先订阅后发布后才能收到消息,

1 可以一次性订阅多个,SUBSCRIBE c1 c2 c3

2 消息发布,PUBLISH c2 hello-redis

3 订阅多个,通配符, PSUBSCRIBE new

4 收取消息, PUBLISH new1 redis2015

image-20200121170832957


notice

欢迎访问 chenyawei 的博客, 若有问题或者有好的建议欢迎留言,笔者看到之后会及时回复。 评论点赞需要github账号登录,如果没有账号的话请点击 github 注册, 谢谢 !

If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !