litestar-org / litestar

Production-ready, Light, Flexible and Extensible ASGI API framework | Effortlessly Build Performant APIs
https://litestar.dev/
MIT License
5.43k stars 372 forks source link

Enhancement: Peristance / ttl no limit for redis streams #3609

Open darekmeco opened 3 months ago

darekmeco commented 3 months ago

Summary

Could you add the ability to set an unlimited TTL (time-to-live) to the RedisChannelsStreamBackend, so that it’s possible to retrieve the history for the entire duration of the stream’s existence?

Basic Example

            plugins=[
                ChannelsPlugin(
                    arbitrary_channels_allowed=True,
                    backend=RedisChannelsStreamBackend(redis=client, stream_ttl=-1),
                )
            ],
PERSIST  LITESTAR_CHANNELS_CHANNEL1

Drawbacks and Impact

No response

Unresolved questions

No response


[!NOTE]
While we are open for sponsoring on GitHub Sponsors and OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.

Fund with Polar

provinzkraut commented 3 months ago

Could you explain your use case for this?

If you don't set any TTL on the stream, you'll have to clean it up manually at some point, otherwise your redis will run out of memory eventually, which is why a default TTL has been added here.