当前位置:网站首页>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
边栏推荐
- Explanation of bitwise operators
- Set up a website with a sense of ceremony, and post it to 1/2 of the public network through the intranet
- Google collab trample pit
- Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
- ScriptableObject
- Attack and defense world misc advanced grace-50
- ECS settings SSH key login
- 剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
- A complete tutorial for getting started with redis: redis usage scenarios
- Redis入门完整教程:GEO
猜你喜欢
OSEK标准ISO_17356汇总介绍
SPH中的粒子初始排列问题(两张图解决)
Redis入门完整教程:初识Redis
The small program vant tab component solves the problem of too much text and incomplete display
Redis getting started complete tutorial: Geo
Unity vscode emmylua configuration error resolution
Redis getting started complete tutorial: Key Management
C语言快速解决反转链表
The new version judges the code of PC and mobile terminal, the mobile terminal jumps to the mobile terminal, and the PC jumps to the latest valid code of PC terminal
浅聊一下中间件
随机推荐
Unity Xiuxian mobile game | Lua dynamic sliding function (specific implementation of three source codes)
Redis: redis configuration file related configuration and redis persistence
剑指 Offer 65. 不用加减乘除做加法
ffmpeg快速剪辑
Advanced area of attack and defense world misc 3-11
Redis入门完整教程:列表讲解
Redis introduction complete tutorial: client communication protocol
vim编辑器知识总结
Redis入門完整教程:Pipeline
Feature scaling normalization
Attack and defense world misc advanced area ditf
[machine learning] handwritten digit recognition
Analysis of environmental encryption technology
浅聊一下中间件
微信公众号解决从自定义菜单进入的缓存问题
MP进阶操作: 时间操作, sql,querywapper,lambdaQueryWapper(条件构造器)快速筛选 枚举类
The new version judges the code of PC and mobile terminal, the mobile terminal jumps to the mobile terminal, and the PC jumps to the latest valid code of PC terminal
Duplicate ADMAS part name
String类中的常用方法
推荐收藏:跨云数据仓库(data warehouse)环境搭建,这货特别干!