Cache LRU (Least Recently Used) usuwa element, który nie był dostępny przez najdłuższy czas, gdy osiągnie limit pojemności. Klasyczne projektowanie łączy hash mapę (O(1) wyszukiwanie) z dwukierunkową listą wiązaną (O(1) zmiana kolejności), dając O(1) dla get i put.
Projektowanie dwóch struktur
HashMap: key -> node DLL (recency order):
MRU <-> ... <-> LRU
get/put: map finds node move touched node to front (MRU)
in O(1); DLL splices it evict the tail (LRU) when full
to the front in O(1)
