Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alternative LRU-based mode for @cached, with support for parameterised operations #83

Open
agarciadom opened this issue Mar 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@agarciadom
Copy link
Contributor

agarciadom commented Mar 15, 2024

Currently, @cached only supports 0-argument context operations, as the cache key only has the context object and the operation name. This is also done to limit the size of the cache: the current @cache is just a Java Map with no eviction policy (which guarantees that a @cached operation is only ever run once). Without an eviction policy, adding parameters to the cache key could dramatically increase the size of the cache if we are not careful.

It would be good to introduce an alternative configuration where @cached is backed by a Guava Cache instead of a Java Map, with a configurable bounded size and with an LRU eviction policy. This new approach could support operations with parameters, but would drop the guarantee that a @cached operation is only ever run once (as a less-used entry may be evicted at some point and may need to be recomputed).

To preserve backwards compatibility in Epsilon 2.x, we should keep the old no-eviction cache as the default behaviour. We may want to reconsider this default in a future 3.x release.

This issue would need both changing the EOL code, as well as extending the .dt plugins to allow for setting whether we want the old no-eviction cache (which only supports 0-arg operations), or the new LRU cache (which supports all operations).

@agarciadom agarciadom added the enhancement New feature or request label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant