medikoo / memoizee

Complete memoize/cache solution for JavaScript
ISC License
1.75k stars 61 forks source link

Is not caching non-promise returning calls the intended behavior? #115

Closed thgreasi closed 4 years ago

thgreasi commented 4 years ago

What is the intended behavior when the provided function throws an error? While giving this a try, it ends up that the call is not cached, but I couldn't find any mention in the docs or a test case: https://runkit.com/embed/w29b07kuc7f9

I like how this works currently but I would want to confirm whether this is the intended behavior. If so, I think it makes sense to mention this in the docs or write a test case, so that we can rely on this behavior in our implementation.

medikoo commented 4 years ago

@thgreasi yes, invocations that crash are not cached. It's intentional. Same with promise mode, if returned promise rejects, then cache is cleared for that invocation.