You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using memoizee, I inject a config variable as the value for maxAge so I can use different values for different environments (prod, dev, testing...).
When setting maxAge: 0 I would expect that the cache is disabled, as every value is cached for 0 milliseconds.. This seems not to be the case, however.
More information, if needed:
On production I use memoizee to minimize calls to other services, to reduce the load.
For testing, I am using nock to mock HTTP responses. At the end of ever test I am verifying if all mocked calls finished successfully. I want that every mocked HTTP response is called, so I want to disable the cache,.
I could introduce a environment flag and then decide based on that whether I memoizee a function or not. But I think maxAge: 0 would be more elegant.
The text was updated successfully, but these errors were encountered:
Thanks for reporting, interesting use case. Currently this setting follows setTimeout behavior. So 0 delays cache purge until callback in setTimeout(fn, 0) is released.
Still I agree that it might be nicer, if it just disables the cache in such case
Makes totally sense. I also have looked into the code and seen the if (!maxAge) return; but I thought maybe the line before (maxAge = timeout(maxAge);) introduces some magic.
I am passing 1 for now, but I would be happy if 0will disable the cache:)
When using memoizee, I inject a config variable as the value for
maxAge
so I can use different values for different environments (prod, dev, testing...).When setting
maxAge: 0
I would expect that the cache is disabled, as every value is cached for 0 milliseconds.. This seems not to be the case, however.More information, if needed:
On production I use memoizee to minimize calls to other services, to reduce the load.
For testing, I am using nock to mock HTTP responses. At the end of ever test I am verifying if all mocked calls finished successfully. I want that every mocked HTTP response is called, so I want to disable the cache,.
I could introduce a
environment
flag and then decide based on that whether I memoizee a function or not. But I thinkmaxAge: 0
would be more elegant.The text was updated successfully, but these errors were encountered: