Redis Pub/Sub
Redis Pub/Sub is a message communication pattern where publishers send messages to channels, and subscribers receive messages from those channels. Redis clients can subscribe to any number of channels, and publishers can send data to any channel.
| Command | Description |
|---|---|
| PSUBSCRIBE | Subscribe one or more channels matching a given pattern |
| PUBSUB | View the status of the subscribe/publish system |
| PUBLISH | Send information to a specified channel |
| SUBSCRIBE | Subscribe messages from one or more specific channels |
| UNSUBSCRIBE | Unsubscribe from a specific channel |
Message Publish/Subscribe Patterns
There are two types of Redis message publish/subscribe patterns: Channel-based and Pattern-based.
Channel-Based Publish/Subscribe Pattern
Publishers can send messages to specified channels, while subscribers can subscribe to one or multiple channels. All subscribers subscribed to this channel will receive messages from it.
Pattern-Based Publish/Subscribe Pattern
The pattern mode includes the concept of channels. Publishers can publish messages for a specific channel, and subscribers can subscribe to specific channels or categories of channels. Subscribers who have subscribed to these specific or categorized channels will receive messages originating from them.