Redis - Publish-Subscribe is used to implement a message broker using Redis. In this lesson, I will show you how to create a message broker using Redis Pub/Sub.
Syntax:
SUBSCRIBE channel_name ...
Example (Subscribe to news channel):
SUBSCRIBE news
Syntax:
PUBLISH channel_name message
Example (Subscribe to news channel):
PUBLISH news "Welcome to Bangladesh"
All subscribers which subscribe to the news channel will receive a "Welcome to Bangladesh" message
Syntax:
PSUBSCRIBE pattern
Example:
PSUBSCRIBE n*
Syntax:
UNSUBSCRIBE channel_name ...
Example (Subscribe to news channel):
UNSUBSCRIBE news
Syntax:
PUNSUBSCRIBE pattern
Example:
PUNSUBSCRIBE n*