[Redis] Publisher/Subscriber

1) What is Publish-Subscribe (pub-sub)?

publish-subscribe(pub-sub) is a messaging pattern where senders of messages, called publishers, do not send the message directly to the receivers, called subscribers, but not instead categorize publishes messages into classes without knowledge of which subscribers.

2) Implementation

  1. On 2 separate clients, subscribe to a key using "SUBSCRIBE <key> <..key(s)>
  2. On a third client, use the key used in step 1 and enter "PUBLISH <key above> <message>"
  3. You should then see the message show up in the two redis clients that subscribed to the key.

3) Unsubscribe

The opposite of subscribing.

4) Pattern matching pub/unsub

Use "PSUBSCRIBE <regex>" or "PUNSUBSCRIBE <regex>"

Resource

Comments

Popular posts from this blog

[Redis] Redis Cluster vs Redis Sentinel

[Unit Testing] Test Doubles (Stubs, Mocks....etc)

[Node.js] Pending HTTP requests lead to unresponsive nodeJS