Skip to content

Cache vs buffer vs memoization

A cache stores values for reuse, a buffer smooths throughput between producer and consumer, memoization is a cache applied to a function's return value.

Aspect

Cache

Buffer

Memoization

Purpose

Faster reads

Smooth throughput

Faster repeated calls

Unit

Key/value

Bytes stream

Function + arguments

Lives in

Every layer

I/O boundary

Function scope

Eviction

LRU, TTL, FIFO

Implicit (drain)

Usually unbounded

Classic example

Redis, CDN

stdio buffer

Fibonacci cache