-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Refresh Policy for items that are expensive to fetch? #338
Comments
I think that I've seen this referred to as I don't think there is anything intelligent we can or should do. Does any of the above solve your problems? |
There is also an extensive discussion about expiry and refresh in another issue, which had similar requirements, see: |
Thank you for your inputs! I will probably go with a scheduled refresh and experiment with different cache policies. |
@ben-manes you wrote:
If I use this approach with an AsyncLoadingCache, with expireAfterWrite set to 5 secs, and iterate using a scheduled job every second over |
Currently when an item is marked for refresh it is eligible for expiration and the work is performed asynchronously on the background executor. This resolves your case, though that may change in the future (#373). There are a few different strategies that you might consider, rather than relying on the above implementation detail.
|
My Java Application needs to cache approx. 1000 JSON objects with an approximate serialized size of 20 KB each. The problem: These objects are very expensive to fetch from the database (response time in the minutes range). Is there a Caffeine refresh policy that allows me to keep the most popular items "hot" after their expiry time?
Imagine a use case where a cached item is accessed until the end of a workday, then expires overnight, which results in a cold cache at the beginning of the next workday. My goal would be to have the most popular items still in the cache the next morning.
The text was updated successfully, but these errors were encountered: