io.ebeaninternal.server.cache.DefaultServerCache Maven / Gradle / Ivy
package io.ebeaninternal.server.cache;
import io.ebean.BackgroundExecutor;
import io.ebean.cache.ServerCache;
import io.ebean.cache.ServerCacheStatistics;
import io.ebean.cache.TenantAwareKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.LongAdder;
/**
* The default cache implementation.
*
* It is base on ConcurrentHashMap with periodic trimming using a TimerTask.
* The periodic trimming means that an LRU list does not have to be maintained.
*
*/
public class DefaultServerCache implements ServerCache {
protected static final Logger logger = LoggerFactory.getLogger(DefaultServerCache.class);
/**
* Compare by last access time (for LRU eviction).
*/
public static final CompareByLastAccess BY_LAST_ACCESS = new CompareByLastAccess();
/**
* The underlying map (ConcurrentHashMap or similar)
*/
protected final Map