There are two ways to write error-free programs; only the third one works. Alan J. Perlis
Least Recently Used (LRU) cache algorithm removes the least recently used items first.
This algorithm keeps track of all items insertion order to delete the least recently used items first. If any item inserts or delete, the cache items lifetime change and update the cache.
LRU size 4.
Insert two number 4 and 5.
The LRU data updated with 2,3,4,5
size:4 Items:0 1 2 3 size:4 Items:2 3 4 5