简体   繁体   中英

does redis pub sub persist historical messages in a channel?

I haven't been able to find in the documentation on how the messages in a channel get stored in redis publish/subscribe.

When you publish to a redis channel, is that message stored or persisted? If so, how long is it stored and how do you get historical messages?

Otherwise, I'm assuming that it just broadcasts that message and drops/deletes that message after doing so?

The pub/sub messages are not queued, and even less persisted.

They are only buffered in the socket buffers, and immediately sent to the subscribers in the same event loop iteration as the publication.

If a subscriber fails to read a message, this message is lost for the subscriber.

You can play with Redis Streams that were released sine 5.0 version. They support persistency and can fit your needs. More details you can find from the article that compares these similar but different data types.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM