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

Option for Max Cache Age? #5

Open
celestialorb opened this issue May 28, 2024 · 0 comments
Open

Option for Max Cache Age? #5

celestialorb opened this issue May 28, 2024 · 0 comments

Comments

@celestialorb
Copy link

celestialorb commented May 28, 2024

I've been examining anycache today and it looks like the perfect solution to a problem I've been having with a small workflow script of mine. However I noticed there doesn't seem to be a way of controlling the maximum amount of time a cached result can live for. In my script I'd like for it to update the cache after it has lived for a certain amount of time (say, every week).

I did see that there's an is_outdated function, but that seems to be based on the source file returning True whenever the source file has been updated (which makes sense).

Could we get an option to specify maxage alongside maxsize for the cached results of a function? e.g.

import datetime

@anycache(cachedir="/path/to/cache", maxage=datetime.timedelta(weeks=1), maxsize=1000000)
def my_anycached_function():
  ...

Passing in None to the maxage parameter could disable the max age check.

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

No branches or pull requests

1 participant