-
Notifications
You must be signed in to change notification settings - Fork 76
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
Stale-while-error functionallity #74
Comments
When a cached item is end of life, the current value will be cached again for For example: lifetime = 300 (5m), refresh_timeout = 30 -> cache weather for 5m, after the lifetime remember the data for another 30 seconds and issue refresh task. If the task fails, cacheback will retry to refresh async after 30 seconds, and again, and again. If the async tasks finishes, the data will be cached for 5m again. |
Ok, I'm gonna look into that. Based on findings I might issue a PR that describes error-scenario's in docs. |
@TBeijen did you write the PR for error-scenarios? Also, is there already an implementation to fetch stale data if celery fails? cc: @stephrdev |
If Celery is down, the same happens as desribed earlier (stale cache kept and extended until a new cache version was generated). |
@stephrdev thank you for the quick response. Is |
We use cacheback a lot for async 'always fast' fetching of data that is requested regularly. Example: Our API exposes weather info. This data is fetched from a 3rd party vendor API. Occasionally that API has quirks for a certain (usually short) period, which (within certain boundaries of course) we want to hide by returning stale data.
If I understand correctly, once a request is made outside of
lifetime
but withincache_ttl
, the entry stored in cache is replaced by one with ttl oftimeout
.So, if request somehow fails, after 'timeout', the cached entry is gone as well, and errors will be visible.
I'd like to elegantly implement a stale-while-error mechanism in Cacheback.
Reference: Similar functionality in Fastly (basically varnish-as-a-service) and Nginx
Haven't looked into implementation but some first thoughts:
fetch()
method that needs to be implemented on a Job subclass, provide a method that can be implemented where errors can be handled.handle_error_while_stale()
for example.fetch()
, catches errors and re-raises something likeAllowedWhileStaleError
Do you see any value in this?
The text was updated successfully, but these errors were encountered: