As I was working on TechScan I needed a way to store some of the chart data in memory for multiple scanners use the same data. My first implementation was a Map but that took too much memory storing old data. I didn't want to use Caffeine and add another dependency so I did a small and simple LRU cache. It has quite an efficient run-time with little overhead.

The idea is the to use a map to track the entries and a double linked list to keep track of what is recently used.

1. Keep a map of Key -> Node(K,V)
2. Keep a linked list of Node(K,V)

for insertion add an entry to the map pointing to the node in the list, and append the node to the end of the list.
for get look up the node using the map, move the node to the end of this list and return the node value.

if during insertion the capacity is reached, remote the HEAD of the list as it is the oldest entry before adding a new node.