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

Make cache LRU #105

Open
schuderer opened this issue Apr 25, 2020 · 0 comments
Open

Make cache LRU #105

schuderer opened this issue Apr 25, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@schuderer
Copy link
Owner

Caching in DataSources (as enabled with an ‘expires’ value other than 0), can be made more fit for purpose by following the Last Recently Used principle instead of, currently, Last Recently Added. That way, the items that are requested more frequently tend to stay in the cache longer. Currently, if an item has been added a longer time ago, it will be removed if enough new items have been added to push it out of the cache FIFO.

This should be trivial to achieve using OrderDict’s move_to_end method in the OrderedDict subclass’ getitem to move the last requested item to the “last added” (end) position of the dict.

However, care must be taken to test this properly and differentiate it from the previous FIFO style in the unit tests.

@schuderer schuderer added the enhancement New feature or request label Apr 25, 2020
@schuderer schuderer added this to To do in Prioritized User Issues via automation May 17, 2021
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
Development

No branches or pull requests

1 participant