LRU (Least Recently Used) cache సామర్థ్యానికి చేరుకున్నప్పుడు, ఎక్కువ సమయం యాక్సెస్ చేయని అంశాన్ని బహిష్కరిస్తుంది. క్లాసిక్ డిజైన్ hash map (O(1) lookup)ని doubly linked list (O(1) మరలా అమర్చడం)తో కలుపుతుంది, ఇది 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)
