एक LRU (Least Recently Used) cache ले आइटमलाई निष्कासन गर्छ जुन सबैभन्दा लामो समयको लागि पहुँच गरिएको छैन जब यो क्षमतामा पुग्छ। क्लासिक डिजाइनले hash map (O(1) lookup) लाई doubly linked list (O(1) reordering) सँग संयोजन गर्छ, जसले O(1) get र put दिन्छ।
दुई-संरचना डिजाइन
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)
