launchdarkly / ruby-server-sdk

LaunchDarkly Server-side SDK for Ruby
https://docs.launchdarkly.com/sdk/server-side/ruby
Other
34 stars 50 forks source link

Ability to manually clear in-memory cache #243

Open aaricpittman opened 8 months ago

aaricpittman commented 8 months ago

Is your feature request related to a problem? Please describe.

When in ldd mode, I would like to be able to manually clear the in-memory cache rather than wait for the expiration.

Describe the solution you'd like

The ability to call client.clear_cache or store.clear_cache or something to that effect which would ultimately call LaunchDarkly::ExpiringCache#clear.

Describe alternatives you've considered

Given the encapsulation of the cache, the only option currently seems to be to close the current client and initialize a new one.

keelerm84 commented 8 months ago

Good morning and thank you for reaching out.

There has some been discussion recently about the behavior of the in memory cache within the SDKs. Would you mind telling me a bit more about your use case so we can capture that need in future discussions?

aaricpittman commented 8 months ago

Sure,

The client used by our Rails app is instantiated with use_ldd: true. We have code in our app that was intended to clear the in-memory cache. There was some confusion and it was believed that it could be cleared calling flush on the client. While looking into another issue I realized that flush wasn't clearing the cache as originally thought and was looking for a way to actually clear it without extending SDK.