-
Notifications
You must be signed in to change notification settings - Fork 68
Add feature: call with freshness threshold #262
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
base: master
Are you sure you want to change the base?
Conversation
Hey Daniel, :) A very cool feature! Thank you for contributing. Please try and solve this. And tag me or @Borda if you need help. Cheers! |
print(f"{test_func(1, 2) = }") | ||
print(f"{test_func(1, 2) = }") | ||
caller_with_freshness_threshold = ( | ||
test_func.caller_with_freshness_threshold( | ||
timedelta(seconds=0.5), | ||
) | ||
) | ||
print(f"{caller_with_freshness_threshold(1, 2) = }") | ||
print(f"{time.sleep(1.0) = }") | ||
print(f"{test_func(1, 2) = }") | ||
print(f"{caller_with_freshness_threshold(1, 2) = }") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are all the prints needed, why just not assert for expected outcomes?
may need some more debugging... 🤔 |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
The feature
In addition to specifying shelf life at storage time, this supports specifying max age at retrieval time.
Motivations
This is useful in interactive projects / data science notebooks.
I personally came to need this when building a cachable API client for Semantic Scholar. (Who knows when's the next groundbreaking paper? I only know how much cache to trust in hindsight.)
How to use
Refer to the test:
Anecdote
can in fact be further reduced to
(how fun!) but then how do you apply
wraps(func)
to type hint it? I haven't the faintest.