Six. Redis Publishing subscription mechanism

Source: Internet
Author: User
Tags redis server

A publish Subscription (PUB/SUB) is a message communication pattern that primarily relieves the coupling of communication between a message publisher and a message subscriber.

As a pub/sub server, Redis serves as a message routing feature between subscribers and publishers. Subscribers can subscribe to the Redis server for the type of message they are interested in by using the Subscribe and Psubscribe commands, and Redis is calling the information type Channel. When a Publisher uses the Publish command to send a specific type of information to Redis server, all clients subscribing to that type of information receive this message.

A client via SUBSCRIBE subscription channel TV1
127.0.0.1:6379> SUBSCRIBE TV1
Reading messages ... (Press Ctrl-c to quit)
1) "Subscribe"
2) "TV1"
3) (integer) 1
1) "Message"
2) "TV1"
3) "Hexu"

b client via SUBSCRIBE subscription channel TV1 TV2

127.0.0.1:6379> SUBSCRIBE TV1 TV2
Reading messages ... (Press Ctrl-c to quit)
1) "Subscribe"
2) "TV1"
3) (integer) 1
1) "Subscribe"
2) "TV2"
3) (integer) 2

Publisher TV1 message via PUBLISH command is Hexu, received by a client and B client

127.0.0.1:6379> PUBLISH TV1 Hexu
(integer) 2

Six. Redis Publishing subscription mechanism

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.