Publish and subscribe for redis

Redis publish-subscribe (pub/sub) is a message communication mode: sender (pub) sends messages and subscribers (sub) receive messages.
Redis clients can subscribe to any number of channels.
The following diagram shows the channel channel1, and the relationship between the three clients subscribed to this channel - client2, client5 and client1:


Example:


other
psubscribe pattern [pattern ...]  
Subscribe to one or more channels that match the given pattern .

pubsub subcommand [argument [argument ...]] 
View subscription and publishing system status.

publish channel message 
sends information to the specified channel.

PUNSUBSCRIBE [pattern [pattern ...]]
Unsubscribes all channels for the given pattern.

SUBSCRIBE channel [channel ...]
Subscribe to the given channel or channels for information.

UNSUBSCRIBE [channel [channel ...]]
means to unsubscribe from the given channel.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326778745&siteId=291194637