-
Notifications
You must be signed in to change notification settings - Fork 47
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
Expose cache age #37
Comments
lxyu (lxyu) wrote: I have got similar problems as well, that I want to make a cache expire but still want the cache to be there while I'm updating it. So I suggest you to take a look at the refresh meth, it can update the cache while others still using the old cache. If you don't have heavy concurrent issue, the current refresh implementation works very well. |
lxyu (lxyu) wrote: FYI, in my case, it's a server-client model which forbid me to use async_creator, but maybe you can use it, it also works. |
s (sontek) wrote: My problem is I don't want to regenerate the cache even if its stale. The operation is extremely heavy and the amount of traffic we get could be regenerating it all the time, so we want to allow the cache to be stale for up to 5 minutes but we need to be able to check how long it has been in cache. |
Michael Bayer (zzzeek) wrote: I think a simple flag "raw=True" on Region.get()/get_or_create(), and then we just make sure to return "value" instead of "value.payload" for both, should be simple. |
Here is a draft of a PR adding a I have the same need to get the age of a value in the cache, in order to be able to fill an |
Grégoire Deveaux has proposed a fix for this issue in the main branch: add method to get the CachedValue / cached time directly https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/5029 |
I made a change to the PR to just use |
Migrated issue, originally created by s (sontek)
Currently dogpile.cache has the created time stored in metadata in the cache, inside value.metadata["ct"] but doesn't expose this anywhere.
We have some very heavy operations and even if the cache gets invalidated, we want to let it stay stale for up to 5 minutes afterwards during high traffic but we need to pull be able to decide when to regenerate the cache based on the size of the survey.
For example,
If we have a survey that has only 10 respondents, we want to invalidate the cache every time a new respondent comes in.
If a survey has 500 respondents or more, even while new respondents are filling out the survey, we would like to leave the cache in place for up to 5 minutes before we regenerate it.
I would be happy with a get_with_metadata and get_or_create_with_metadata, that way after the call I could inspect the age of the cache from metadata['ct'] and decide if I should invalidate it.
The text was updated successfully, but these errors were encountered: