Monday, January 12, 2015

LRU Cache with pruning thread

Objective: Create a generic LRU cache with prune mechanism in different thread.

Approach: LRU cache stand for least recently used cache. In java, it is very common to use LinkedHashMap to implement this functionality. But, pruning process is also important. If we will do pruning process in same thread as adding LRU cache, it will take time. So, here is multi-threaded solution for this problem. We will add item in LRU cache, and prune old item in other thread.

Download full source code: LRU cache complete source code

Solution: Java Code

No comments:

Post a Comment