A cache from a map and a list.
transcript
A cache must forget. It forgets the oldest use. And it must be instant. Two structures do it. Real systems do this all day. It takes two parts.
A key goes in. The map gives its node. One step. No search. A hash map is that fast.
Most recent at the front. Least recent at the back. A use moves a node to the front. Two writes out, four in. No search is needed. The front is the freshest.
The cache is full. A new key arrives. The back node leaves. The map forgets its key. Nothing else moves. The oldest goes first.
The list alone must search. The map alone has no order. Together, both are instant. Get and put cost constant time. Neither one is enough.
The map finds. The list orders. Build it in the lab. Get and put stay constant. A map finds, a list orders. Full breakdown in the lecture.