Redis QuickStart-Redis Publish subscriptions (12)

Source: Internet
Author: User

The pub sub of Redis implements mail systems, messages sent by senders (known as publishers in Redis terminology), and receivers (users) receiving them. The link is referred to by the message and is called a channel.

Redis clients can subscribe to any number of channels.

Example

The following is an example of how to publish a user's concept work. In the following example, a client subscription is given a channel named Redischat

Redis 127.0.0.1:6379> SUBSCRIBE Redischat

Reading message ... (Press Ctrl-c to quit)

1) "Subscribe"

2) "Redischat"

3) (integer) 1

Now, two clients are published in the same channel name Redischat message and above the subscribing client receives the message.

Redis 127.0.0.1:6379> pblish redischat "Redis is a great caching technique"

(integer) 1

Redis 127.0.0.1:6379> PUBLISH redischat "Learn Redis by Tutorials Point"

(integer) 1

1) "Message"

2) "Redischat"

3) "Redis is a great cacheing technique"

1) "Message"

2) "Redischat" "

3) "Learn Redis by Tutorials Point"

Redis PubSub Command

Some basic commands related to Redis PubSub are shown in the following table:

S.N. Command & Description
1

Psubscribe pattern [pattern ...]

The subscription channel matches the given pattern

2

PUBSUB subcommand [argument [argument ...]

Describes the PubSub system, for example, its customer is active on the server state

3

PUBLISH Channel Message

Publish a message to the channel

4

Pubsubscribe [pattern [pattern ...]]

Stop listening for messages that do not send a channel to match a given pattern

5

SUBSCRIBE Channel [Channel ...]

Listens to the specified channel information

6

unsubscribe [Channel [channel ...]]

Stop listening to publish a given channel information

Redis QuickStart-Redis Publish subscriptions (12)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.