LinkedHashMap Example: LRU Cache Implementation

LRU cache can be implemented fairly easily using LinkedHashMap. In this article we examine what is LRU cache and how to implement it in Java. What is LRU Cache? LRU cache stands for least-recently-used cache. Before we examine the LRU policy, let’s take a moment to see what a cache is. What is a cache? In… Continue reading LinkedHashMap Example: LRU Cache Implementation

LinkedHashMap with Example

LinkedHashMap is a sub-class of Java HashMap with capabilities to keep keys ordered either in insertion order or access order. LinkedHashMap is the dictionary/table implementation of choice whenever you want best performance and predictable key ordering at the same time. It achieves this magical feat by maintaining a doubly linked list apart from the usual implementation of HashMap. The doubly-linked list is used to… Continue reading LinkedHashMap with Example