-
Notifications
You must be signed in to change notification settings - Fork 22
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
Pass cache result into ttl function #149
Comments
Thanks , I'll think about this feature Am I right that prev_cache_result is a last result in cache ? in this case it is only possible with early ( https://github.com/Krukov/cashews#early ) or hit strategy (a cached value should be still in a storage) |
Yes, that's right. But I have another better idea - we can calculate ttl after receiving result. Then this becomes really powerful. |
So this becomes: def my_ttl_calculation(a: int, result: Any):
if isinstance(result, MyException):
return "5m"
return "10s"
@cache(ttl=my_ttl_calculation)
def my_func(a: int):
... |
yep I like it more then passing prev result. I'll definitely implement it |
use a result of call in cache ttl def #149
released 6.3.0 |
With new exceptions api (#143), this feature may be super useful.
The text was updated successfully, but these errors were encountered: