I would not recommend using memoize()for this. He defeats the goal of memoization, which is to cache computational results that never change for a given set of inputs.
If you want to build a TTL cache, I would recommend looking at wrap () . Use this to wrap your functions with a generic function that performs cache and TTL checks.
source
share