当前位置:网站首页>Redis: redis message publishing and subscription (understand)
Redis: redis message publishing and subscription (understand)
2022-07-04 23:05:00 【dengfengling999】
In order to realize the communication of the client , Provides the concept of channel
1.Redis Publish subscribe
Redis Publish subscribe (pub/sub) It's a message communication mode : sender (pub) Send a message , subscriber (sub) receive messages .Redis Clients can subscribe to any number of channels .
Redis Publish and subscribe diagram
Figure 1 : Message subscribers (client2 、 client5 and client1) Subscribed Channels channel1:
Figure 2 : The publisher publishes messages to the channel channel1, Will be sent to three subscribers :
Redis Common commands for publishing and subscribing
1.subscribe
grammar :subscribe channel [channel…]
function : Subscribe to information about one or more channels
Return value : Subscribed messages
for example :
2.publish
grammar :publish chanel message
function : Send the message to the specified channel .
Return value : Numbers . Number of message subscribers received .
Another client :
ch1 Just received
3.psubscribe
grammar :psubscribe pattern [pattern]
function : Subscribe to one or more channels that match the given pattern . Mode with * As a wildcard , for example :news.* Match all to news. The first channel .
Return value : Subscription information .
because Redis The function of is single , And unstable
It will not be used in actual development , Publish and subscribe to client messages , We will learn a technology that specializes in message communication and publishing
边栏推荐
- Redis入门完整教程:HyperLogLog
- Google Earth engine (GEE) -- take modis/006/mcd19a2 as an example to batch download the daily mean, maximum, minimum, standard deviation, statistical analysis of variance and CSV download of daily AOD
- [graph theory] topological sorting
- 攻防世界 MISC 进阶区 can_has_stdio?
- Redis入门完整教程:键管理
- Create Ca and issue certificate through go language
- Install the gold warehouse database of NPC
- Docker镜像的缓存特性和Dockerfile
- Explanation of bitwise operators
- [ODX studio edit PDX] - 0.2-how to compare two pdx/odx files of compare
猜你喜欢
ETCD数据库源码分析——处理Entry记录简要流程
heatmap. JS picture hotspot heat map plug-in
[roommate learned to use Bi report data processing in the time of King glory in one game]
Redis入門完整教程:Pipeline
EditPlus--用法--快捷键/配置/背景色/字体大小
【剑指Offer】6-10题
OSEK标准ISO_17356汇总介绍
S32 Design Studio for ARM 2.2 快速入门
【图论】拓扑排序
P2181 对角线和P1030 [NOIP2001 普及组] 求先序排列
随机推荐
Google Earth engine (GEE) - globfire daily fire data set based on mcd64a1
Summary of wechat applet display style knowledge points
Complete tutorial for getting started with redis: bitmaps
【ODX Studio编辑PDX】-0.2-如何对比Compare两个PDX/ODX文件
ffmpeg快速剪辑
P2181 对角线和P1030 [NOIP2001 普及组] 求先序排列
金融市场,资产管理与投资基金
【ODX Studio編輯PDX】-0.2-如何對比Compare兩個PDX/ODX文件
mamp下缺少pcntl扩展的解决办法,Fatal error: Call to undefined function pcntl_signal()
heatmap. JS picture hotspot heat map plug-in
[machine learning] handwritten digit recognition
OSEK标准ISO_17356汇总介绍
[OpenGL] note 29 anti aliasing (MSAA)
A complete tutorial for getting started with redis: redis usage scenarios
UML diagram memory skills
Google Earth engine (GEE) -- take modis/006/mcd19a2 as an example to batch download the daily mean, maximum, minimum, standard deviation, statistical analysis of variance and CSV download of daily AOD
[odx Studio Edit pdx] - 0.2 - Comment comparer deux fichiers pdx / odx
Notepad++ -- editing skills
Attack and defense world misc advanced grace-50
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先