Least used, not oldest
transcript
A cache is full, and a new key arrives. One key must go. Which one? The oldest key is a tempting answer. But it can be the wrong one.
The key with the fewest uses is evicted first. If several tie, evict the one used longest ago.
Key one was used three times, but it is the oldest. Evicting the oldest drops it, and the last access misses. Evicting the least used drops key two instead. The last access hits.
Evicting the least used key gives three hits. Evicting the oldest key gives only two.
Keep one list for each use count. A use moves the node to the next list. Evict from the lowest list, at its oldest end.
When two keys have the same count, the tie needs a rule. Evict the key that was used longest ago.
Evict by count, then by age. One list per count keeps it fast. Full breakdown in the lecture.