Reputation: 11741
What mechanism(s) does Redis use to keep messages in memory in case of pub-sub ? If no client is subscribed what happens to the messages? Will Redis buffer them ? Is there a way to configure the min. and max. memory allocated per channel ?
Upvotes: 10
Views: 4126
Reputation: 16121
Redis does not keep messages in memory in the Pub/Sub context as you can see in the implementation (x):
Then Redis simply returns how many clients have received the message (keeping in mind that a client may receive a single message multiple times e.g if multiple pattern matches).
If there is no client subscribed, Redis simply returns 0 and the message is not recorded/buffered:
> publish foo test
(integer) 0
(x) basically Redis loops over the list of subscribed clients and sends a reply with the message.
Upvotes: 16