Redis Publish Subscriptions

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 transmitted by this message is called a channel.

Redis clients can subscribe to any number of channels.

Example

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

Redis 127.0.0.1:6379> SUBSCRIBE redischatreading messages ... (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> PUBLISH redischat "Redis is a great Caching technique" (integer) 1redis 127.0.0.1:6379> PUBLISH Redischat "Learn Redis by Tutorials Point" (integer) One) "message" 2) "Redischat" 3) "Redis is a great caching 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, such as its customer status on the server.
3 PUBLISH Channel Message
Publishes a message to the channel.
4 Punsubscribe [pattern [pattern ...]]
Stops listening for messages that are published to the channel to match a given pattern.
5 SUBSCRIBE Channel [Channel ...]
The listener is published to the specified channel information.
6 unsubscribe [Channel [channel ...]]
Stops the listener from publishing the given channel information.





Article reprinted from: Yi Hundred tutorials [http:/www.yiibai.com]

Article title: Redis Publish Subscription
This address: http://www.yiibai.com/redis/redis_pub_sub.html

Redis Publish Subscriptions

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.