当前位置:网站首页>NoSQL数据库之Redis(四):Redis的发布和订阅
NoSQL数据库之Redis(四):Redis的发布和订阅
2022-06-29 06:37:00 【Tina-Deng】
什么是发布和订阅
Redis 发布订阅 (pub/sub) 是一种消息通信模式:发送者 (pub) 发送消息,订阅者 (sub) 接收消息。
Redis 客户端可以订阅任意数量的频道。
Redis的发布和订阅
1、客户端可以订阅频道,如下图:
2、当给这个频道发布消息后,消息就会发送给订阅的客户端
发布订阅命令行实现
1、打开一个客户端订阅channel1
SUBSCRIBE channel1

2、 打开另一个客户端,给channel1发布消息hello
publish channel1 hello

返回的1是订阅者数量
3、打开第一个客户端可以看到发送的消息
注:发布的消息没有持久化,如果在订阅的客户端收不到hello,只能收到订阅后发布的消息
边栏推荐
- Delete tag
- flutter配置国内镜像,连接真机
- About DDNS
- It is the only one in China that Alibaba cloud container service has entered the Forrester leader quadrant
- Pointer from beginner to advanced (2)
- QT (x): packaging and deployment
- How to do the performance pressure test of "Health Code"
- The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
- Overlay histogram with density curve
- 关于 localStorage 的一些高阶用法
猜你喜欢
随机推荐
json tobean
2022.02.15 - 240. Lucky number in matrix
try anbox (by quqi99)
Li Kou today's question -324 Swing sort II
VerilogA——动态比较器
层次分析法
QT (x): control operation
用机器人教育创造新一代生产和服务工具
Antlr4 recognizes the format of escape string containing quotation marks
flutter配置国内镜像,连接真机
Daily question - force deduction - multiply the found value by 2
Testing grpc service with grpcui
Qt 容器类
Li Kou daily question - day 30 -1523 Number of bit 1
QT qframe details
关于 localStorage 的一些高阶用法
As a qualified network worker, you must master DHCP snooping knowledge!
RPC and RMI
Move disassembly of exclusive delivery of script (the first time)
MySQL learning notes








