-
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
keeping stale values in case the backend is offline #385
Comments
Perhaps a victim cache would work? In that case when the writer synchronously evicts, you capture it into a secondary cache. A subsequent loader call could fetch it, resurrecting the entry. That might provide the lifecycle hack that you’re looking for. |
which writer? do you mean an external thread that invalidates the cache? |
I meant if you supply a |
do you mean a configuration like your comment here? |
Yes, something like that might work? |
I think it might work. thanks! |
Hello, Have you found a solution to this problem? Could you share it? Sad that there is no such thing out of the box. |
Look in the example above by @ben-manes . also, note that with a loadingCache, a backend failure will throw an exception and the mapping is unchanged so you get the old value by default (if it was there already) |
Hey,
First, thanks for this great library.
I would like to configure Caffeine to save stale values in case the backend is off. This means if you cache a DB query and the DB query, and the DB goes offline for some reason. The cache would preserve the same values even after they are considered stale. This is because, in a few use cases, a stale value is better than no value.
This is doable with
refreshAfterWrite
but this API is not as flexible asexpireAfter
. This might be a duplicate of #360 but I wonder if there is another way (even if less straightforward) of doing so.The text was updated successfully, but these errors were encountered: