当前位置:网站首页>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
边栏推荐
- Principle of lazy loading of pictures
- D3.js+Three. JS data visualization 3D Earth JS special effect
- 微信公众号解决从自定义菜单进入的缓存问题
- A complete tutorial for getting started with redis: transactions and Lua
- S32 Design Studio for ARM 2.2 快速入门
- Attack and defense world misc advanced area ditf
- Redis入门完整教程:GEO
- Install the gold warehouse database of NPC
- vim编辑器知识总结
- Photoshop batch adds different numbers to different pictures
猜你喜欢
Unity vscode emmylua configuration error resolution
Attack and defense world misc advanced area ditf
浅聊一下中间件
Redis入门完整教程:初识Redis
位运算符讲解
Attack and defense world misc master advanced zone 001 normal_ png
Redis入门完整教程:列表讲解
Attack and defense world misc advanced area can_ has_ stdio?
[graph theory] topological sorting
debug和release的区别
随机推荐
【剑指offer】1-5题
Attack and defense world misc advanced area ditf
Docker镜像的缓存特性和Dockerfile
Redis introduction complete tutorial: List explanation
[roommate learned to use Bi report data processing in the time of King glory in one game]
Persistence mechanism of redis
JS 3D explosive fragment image switching JS special effect
C语言快速解决反转链表
[try to hack] wide byte injection
[OpenGL] note 29 anti aliasing (MSAA)
Attack and defense world misc master advanced zone 001 normal_ png
浅聊一下中间件
【ODX Studio编辑PDX】-0.2-如何对比Compare两个PDX/ODX文件
Redis入门完整教程:Bitmaps
头文件重复定义问题解决“C1014错误“
cout/cerr/clog的区别
Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
Redis入门完整教程:键管理
Redis: redis configuration file related configuration and redis persistence
该如何去选择证券公司,手机上开户安不安全