ایک 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)
