In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "What is Redis publishing subscription mode". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "what is Redis publish subscription mode"!
publish/subscribe interaction pattern
Role relationships:
The client has two roles: publisher and subscriber
Publishers and subscribers are linked through channels
Interaction direction:
Publisher interaction with Redis servers remains request/response mode
Server sends data to subscribers (push)
Timing: Push sent after the server receives the publisher message
Two types of channels
Normal channel: Subscribers bind/unbind themselves to a Channel through SUBSCRIBE/UNSUBSCRIBE; the publisher's publish command specifies which channel to send a message to, and then the server forwards the message to the subscribers bound to the channel.
pattern channel: Subscribers bind/unbind themselves to a pattern channel through PSUBSCRIBE/PUNSUBSCRIBE; the publisher's publish command specifies which channel a message is sent to, and the server matches the channel name with the pattern channel name. If the match is successful, the message will be forwarded to the subscribers bound to this pattern channel.
Implementation of subscription relationships
Subscriptions to channels are maintained at the Redis instance level, independent of the key-value hierarchy of redisDb.
typedef struct redisServer{ ... dict *pubsub_channels; dict *pubsub_patterns; ...}
pubsub_channels map maintains the relationship between ordinary channels and subscribers: key is the name of the channel, value is a pointer list of all its subscribers
pubsub_patterns maintains the relationship between pattern channels and subscribers: each element of the list contains two parts (the name of the pattern channel and the client pointer to subscribe to it)
When a publisher publishes a message to a channel, redis first finds the corresponding value from pubsub_channels and sends the message to all its clients; at the same time, it iterates through the pubsub_patterns list and sends the message to clients that match the element.
At this point, I believe that everyone has a deeper understanding of "what is Redis publish subscription mode", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.