I\'m constantly hearing about person y had performance issue x which they solved through caching.
Or, how doing x,y,z in your programs code can hurt your caching abil
Caching does not necessarily only apply to 'oft retrieved' values but to anything you can save time on by reducing the number of times you recompute it. A simple example that comes to mind is calculating the fibonacci sequence. The simplest recursive implementation looks like this (in psuedo-code):
function f(n)
if n < 2 then
return n;
return f(n - 1) + f(n - 2)
This can be improved with caching to prevent recalculating already known values:
fib_cache = {}
function f(n)
if n < 2 then
return n;
if fib_cache.contains(n) then
return fib_cache[n]
fib_cache[n] = f(n - 1) + f(n - 2)
return fib_cache[n]