feat: Use stale while revalidating #22
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a new type of request ancestor. This has two cache timeouts, a short one indicates when it's time to start a background process to revalidate the data. A long one holds on to a known good result for a maximum hold time.
When a request is asked for that is later than the refreshCacheKey we return the responseFromCache and defer a job to run this request that will not read from cache but will upon completion write to cache. This wall all callers are served in the much faster response time, but results are still routinely updated behind the scenes.