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

Feature request: Return stale value while revalidating #19

Closed
futpib opened this issue May 23, 2021 · 10 comments · Fixed by #26
Closed

Feature request: Return stale value while revalidating #19

futpib opened this issue May 23, 2021 · 10 comments · Fixed by #26

Comments

@futpib
Copy link

futpib commented May 23, 2021

When used with maxAge option, when the cache entry has expired, memoized function could return last cached value while waiting for a new result to arrive.

@papb
Copy link

papb commented May 24, 2021

I think this could be an option, but not on by default.

@sindresorhus
Copy link
Owner

Yeah, sounds useful as an opt-in option.

@AmrSaber
Copy link

Hello @sindresorhus, I am interested in helping out with this feature. How can I help with it?

@Richienb
Copy link
Contributor

@AmrSaber PRs are always welcome

@AmrSaber
Copy link

I don't understand how #26 closes this ticket? How do we achieve the stale-while-revalidate scenario now?

@Richienb
Copy link
Contributor

#26 Moves this feature into userland.

@AmrSaber
Copy link

AmrSaber commented Nov 1, 2021

Can you show an example of how to achieve this?

@Richienb
Copy link
Contributor

Richienb commented Nov 2, 2021

False alarm: after the previous PR, I'm not sure how to check if a value is stale anymore to then call the function again.

@futpib
Copy link
Author

futpib commented Nov 3, 2021

Should this be reopened then?

@Richienb
Copy link
Contributor

Richienb commented Nov 3, 2021

Yes, but with the new goal of adding an API to the cache storage object to check whether the object is stale and whether stale-while-revalidate should be used

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

Successfully merging a pull request may close this issue.

5 participants