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 implementation for Suppliers#memoizeWithRefresh #3777

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

StephenFlavin
Copy link

@StephenFlavin StephenFlavin commented Jan 22, 2020

In response to #872 (comment) I'd like to submit this PR for discussion.

I began looking into this when trying to find a way to make my apps existing LoadingCache<K, V> populate itself with all of the possible keys and values it could from my database table, in my use case the input data is dynamic and contains keys which may or may not have a value in the database however, the database table is quite small and could easily be completely stored in memory and refreshed at a set interval, this will reduce the number of calls my app needs to make to the database exponentially(>10k requests per minute to 1 request per 15 minutes).
While searching I came across this issue #775 which is exactly the same problem I am trying to solve but I fear there was some confusion in the reasons why and the use case.

I would prefer if there was an implementation of LoadingCache that had these semantics but for now I thought a smaller change would be to add an extra implementation to memoized suppliers.

I am aware that the tests here are less than idea, I just followed the convention from the tests of the expiring memoizer which uses Thread.sleep.

There is a good chance I've missed something which exists that does exactly what I require so if you know if it please tell me 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants