-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
max: 0
doesn't disable cache.
#145
Comments
@monkekode, what exactly is your use case? Why set up memoization when you don't want caching? Behind the scenes, Line 13 in 6aa3746
|
I have an endpoint on the site that calls a slow external API. If 2+ requests come to my site at the same time, I don't want to have 2+ concurrently running requests going to the external API, I want the requests that came while the first one was underway to wait for the first one to finish and receive the same result. I also don't want to cache the response since it changes over time. This works with |
@monkekode In this case I believe you need to first decide when you consider the response you eventually cached is stale (likely not up to date anymore. Having that you should achieve that with following options:
If you want the responses to be freed from cache near immediately after they're obtained, just set |
Ok, thanks. Max age of 1 ms is fine in this case, although it would be nice to have the ability to just disable the cache altogether, maybe a max: 'no-cache' or something like that. |
@monkekode I'm not sure if disabling cache is right solution here. It's clear that you want to cache value, but just for a repeated requests which may happen when first one still is not fulfilled One improvement coud be to support |
Hi, I'm trying to memoize a function to the point where there is no cache, but concurrent execution also doesn't happen. To do this
max: 0
should work to disable cache, but in practice it doesn't. Example:In this case output is
Meaning the values are memoized. Setting
max
to 1 works properly, as do higher values.The text was updated successfully, but these errors were encountered: