Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of Pub/Sub in Redis

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

What is the role of Pub/Sub in Redis? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Redis publishes commands related to the subscription model.

PSUBSCRIBE

Earliest available version: 2.0.0

Time complexity: O (N), N is the number of subscribed clients.

A client that subscribes to a given rule in the following forms:

H?llo subscribes to hello,hallo, hxllo, etc.

H*llo subscribes to hllo, heeeello, etc.

H [ae] subscribe to hello and hallo, but not to hillo

If you want to match verbatim, use\ to escape special characters.

PUBLISH

Earliest available version: 2.0.0

Time complexity: O (NumberM), N is the number of subscribed clients, M is the total number of subscriptions

Post a message to the specified channel.

PUBSUB

Earliest available version: 2.8.0

Time complexity: O (N), N is the number of active channels

This command is used to check the status of the Pub/Sub subsystem.

1PUBSUB CHANNELS [pattern]

List the currently active channels (with at least one subscriber). However, if you do not specify pattern, all channels are listed.

1PUBSUB NUMSUB [channel-1... Channel-N]

Returns the subscriber of the specified channel.

1PUBSUB NUMPAT

Returns the number of subscriptions for the specified pattern (executed using the PSUBSCRIBE command)

PUNSUBSCRIBE

Earliest available version: 2.0.0

Time complexity: O (NumberM), N is the number of subscriptions that have been subscribed by clients that match rules, and M is the total number of subscriptions to matching rules in the system

Usage: PUNSUBSCRIBE [pattern [pattern …]]

Unsubscribe all channels that match the rules, or unsubscribe all channels if no rules are specified.

SUBSCRIBE

Earliest available version: 2.0.0

Time complexity: O (N), N is the number of subscription channels

Subscribe to the specified channel to the client.

After reading the above, have you mastered the role of Pub/Sub in Redis? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report