How an LRU cache decides what to throw out
How an LRU cache decides what to throw out
A cache only has so many slots. So what goes when it is full?
Every item you use moves to the front. When a new one arrives and there is no room, the one at the back goes: the one nobody has touched for the longest. That is LRU, least recently used.
Here: A, B, C, D fill four slots. B is used again and jumps to the front. E arrives, and A is out.
Save this for your next system design interview.
#coding #computerscience #systemdesign #programming #technology