当前位置:网站首页>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,只能收到订阅后发布的消息
边栏推荐
- Aging design guide for applets
- JDBC连接数据库,socket发送客户端。
- Print Yanghui triangle
- Daily question - force deduction - multiply the found value by 2
- 消息队列之通过幂等设计和原子锁避免重复退款
- Overlay histogram with density curve
- 2022.02.15 - 240. Lucky number in matrix
- What should I learn before learning programming?
- try anbox (by quqi99)
- json tobean
猜你喜欢

Message queue avoiding repeated refund by idempotent design and atomic lock

jetson tx2

How to change the password after forgetting the MySQL password (the latest version of 2022 detailed tutorial nanny level)

The annual technology inventory of cloud primitives was released, and it was the right time to ride the wind and waves

Annual inventory review of Alibaba cloud's observable practices in 2021

UVM authentication platform

Li Kou today's question -324 Swing sort II

Share 10 interview questions related to JS promise

Easy to understand TCP four waves (multi picture explanation)

Delete tag
随机推荐
Analytic hierarchy process
RPC和RMI
jetson tx2
Illegal forward reference and enums
Are there too many programmers in China at present?
VerilogA - dynamic comparator
Qt 自定义位操作类
What is 'EC2-Other' filter in 'Cost Explorer' dashboard mean? [closed]
关于 localStorage 的一些高阶用法
Testing grpc service with grpcui
Print Yanghui triangle
Pointer from beginner to advanced (2)
Fault: ntfrs warning log for id13562
RPC and RMI
Qt QLineEdit详解
The echares map is implemented separately by provinces, and the tooltip user-defined prompt box, scattered annotation and scattered illumination are explained in detail
QT (x): control operation
Annual inventory review of Alibaba cloud's observable practices in 2021
JDBC | Chapter 6: simple use of database connection pool
Analysis comp122 the Caesar cipher