Closed Colex closed 9 years ago
(I'm a maintainer of a downstream fork)
This is a very cool PR, except that you recalculate the function as long as the value is null
(even that it is a proper own-property of the cache).
I don't think this method belongs in the cache layer. With ES6 Promises I can see an approach using standard promises, but not as this PR stands.
Added the option use the cache within a non blocking friendly flow. It is based on Rails' cache fetch function but adapted to javascript and a non-blocking architecture.
The current API is for the fetch function is:
expensive_callback is a non blocking function that calculates the value for the given key. It is only called if there is a cache miss. In the case there is no cache miss, result_callback will be called instantaneously with the value.
Here is one example of usage: