एक LRU (Least Recently Used) कैश वह आइटम निकाल देता है जिसे सबसे लंबे समय से एक्सेस नहीं किया गया है जब यह क्षमता तक पहुंचता है। क्लासिक डिज़ाइन एक hash map (O(1) lookup) को एक doubly linked list (O(1) पुनः क्रमण) के साथ जोड़ता है, जो O(1) get और put देता है।
The two-structure design
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)
