In my app I dynamically create new pubsub
channels and there might be too many like 5k per day. According to my app's requirements any channel is used for at most 5minutes.
Considering this situation, thousands of unused channels will be present in the app in a week. So how can I delete unused channels or should I even delete them. Do they stored in memory? What happens to the messages published via them, do they stay on the redis' memory?
thanks
Aside from data storage, Redis can be used as a Publisher/Subscriber platform. In this pattern, publishers can issue messages to any number of subscribers on a channel. These messages are fire-and-forget, in that if a message is published and no subscribers exists, the message evaporates and cannot be recovered.
There is no hard limit in Redis on maximum number of channels; it is user configurable. Save this answer.
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.
A Publish-Subscribe Channel works like this: It has one input channel that splits into multiple output channels, one for each subscriber. When an event is published into the channel, the Publish-Subscribe Channel delivers a copy of the message to each of the output channels.
Channels are ambient. They only exist while there are subscriptions. So: either call [P]UNSUBSCRIBE from the connections that subscribed, or close the connections that subscribed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With