Comparison
In-process cachevsMemoisation
In-process cache
you keep the values in the application's own memory, so lookups are free and every instance ends up with a slightly different copy.
A cache living inside the service process. It is the fastest option available, with no network hop, and it is the only one that keeps working when the shared cache is unreachable. The cost is that it multiplies by instance count: N replicas mean N copies to warm, N copies to invalidate, and N chances to serve a different answer to two users at the same moment.
Full entry →Memoisation
you cache the return value of a pure function inside the process so calling it twice with the same arguments only computes once.
In-process caching keyed on a function's arguments, valid only where the function is genuinely pure. It is the cheapest caching there is, with no network hop and no serialisation. It is also invisible to your invalidation story: memoised values live until the process dies, which is why it belongs on computation, not on anything that reads state.
Full entry →