LRU (Least Recently Used) cache એ ક્ષમતાએ પહોંચે ત્યારે સૌથી લાંબા સમયથી ઍક્સેસ ન થયેલ આઇટમને હટાવે છે. ક્લાસિક ડિઝાઇન hash map (O(1) lookup) અને doubly linked list (O(1) reordering) ને જોડે છે, જે O(1) get અને put આપે છે.
The two-structure design
text
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)
