I’m reaching back to a previous question I had: Frequently Used metadata Hashmap
However, this time how would I adapt that solution to work with ConcurrentMap? LinkedHashMap isn’t a synchronized collection, and due to performance reasons I don’t want to wrap it in sycronizedMap. Is there an alternative [concurrent friendly] solution to solve this problem?
The original problem was that I need a hash map that gets rid of the least used items after so many entries.
The Guava
MapMakerandCacheBuilderclasses can generate concurrent maps with an LRU eviction policy.The
CacheBuilderclass is preferred for caching use-cases, as the Guava developers are in the process of stripping the cache support methods out ofMapMaker.