ਇੱਕ 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)
