当前位置:网站首页>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
边栏推荐
- Qt加法计算器(简单案例)
- Redis入門完整教程:Pipeline
- Attack and defense world misc master advanced zone 001 normal_ png
- 微信小程序显示样式知识点总结
- One of the commonly used technical indicators, reading boll Bollinger line indicators
- Sword finger offer 68 - ii The nearest common ancestor of binary tree
- Google collab trample pit
- SHP data making 3dfiles white film
- VIM editor knowledge summary
- 图片懒加载的原理
猜你喜欢
随机推荐
Gnawing down the big bone - sorting (II)
[graph theory] topological sorting
Redis getting started complete tutorial: hash description
P2181 diagonal and p1030 [noip2001 popularization group] arrange in order
小程序vant tab组件解决文字过多显示不全的问题
Redis入门完整教程:键管理
heatmap. JS picture hotspot heat map plug-in
Sword finger offer 68 - I. nearest common ancestor of binary search tree
[OpenGL] note 29 anti aliasing (MSAA)
微信公众号解决从自定义菜单进入的缓存问题
Redis入门完整教程:有序集合详解
Analysis of environmental encryption technology
mamp下缺少pcntl扩展的解决办法,Fatal error: Call to undefined function pcntl_signal()
Is Huatai Securities a nationally recognized securities firm? Is it safe to open an account?
Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
Install the gold warehouse database of NPC
Common methods in string class
企业如何跨越数字化鸿沟?尽在云原生2.0
剑指 Offer 65. 不用加减乘除做加法
9 - class






![[machine learning] handwritten digit recognition](/img/26/cabdc5c92035181d82f6f809e6df0f.png)

