An LRU (Least Recently Used) cache evicts the item that hasn't been accessed for the longest time when it hits capacity. The classic design combines a hash map (O(1) lookup) with a doubly linked list (O(1) reordering), giving O(1) get and 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)
