Cache expensive operations in memory. With timeout and (optionally) fixed cache size, so it doesn't grow unbound.