3 ms·
It really depends on what you're trying to cache. Caching expensive calculations e.g. is trivial to get right (use all arguments as cache key) and often you don
by creshal 10y ago
It really depends on what you're trying to cache. Caching expensive calculations e.g. is trivial to get right (use all arguments as cache key) and often you don't even need invalidation (unless your algorithm changes at runtime).
- Klathmon 10y agoMemoization works amazingly and can be very easy to implement, but it's not always that applicable. In my experience, I just don't hit that many pure functions that don't do things like touch the database (which can change out from under the function), or are called enough with the same arguments that memoization is actually worth it. But when it does work, it's like magic. I do a lot of work in javascript now, and it's great being able to wrap a function in a single line `memoize` function and instantly improve performance.