com.fasterxml.jackson.jaxrs.util.LRUMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ehcache Show documentation
Show all versions of ehcache Show documentation
Ehcache is an open source, standards-based cache used to boost performance,
offload the database and simplify scalability. Ehcache is robust, proven and full-featured and
this has made it the most widely-used Java-based cache.
package com.fasterxml.jackson.jaxrs.util;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Helper for simple bounded LRU maps used for reusing lookup values.
*
* @since 2.2
*/
@SuppressWarnings("serial")
public class LRUMap extends LinkedHashMap
{
protected final int _maxEntries;
public LRUMap(int initialEntries, int maxEntries)
{
super(initialEntries, 0.8f, true);
_maxEntries = maxEntries;
}
@Override
protected boolean removeEldestEntry(Map.Entry eldest)
{
return size() > _maxEntries;
}
}