Package io.ebeaninternal.server.cache
Class DefaultServerCache
- java.lang.Object
-
- io.ebeaninternal.server.cache.DefaultServerCache
-
- All Implemented Interfaces:
ServerCache
- Direct Known Subclasses:
DefaultServerQueryCache
public class DefaultServerCache extends Object implements ServerCache
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultServerCache.CacheEntry
Wraps the value to additionally hold createTime and lastAccessTime and hit counter.static class
DefaultServerCache.CompareByLastAccess
Comparator for sorting by last access time.class
DefaultServerCache.EvictionRunnable
Runnable that calls the eviction routine.
-
Field Summary
Fields Modifier and Type Field Description static DefaultServerCache.CompareByLastAccess
BY_LAST_ACCESS
Compare by last access time (for LRU eviction).
-
Constructor Summary
Constructors Constructor Description DefaultServerCache(DefaultServerCacheConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the cache.Object
get(Object id)
Return a value from the cache.long
getHitCount()
Return the count of get hits.int
getHitRatio()
Return the hit ratio the cache is currently getting.long
getMissCount()
Return the count of get misses.String
getName()
Return the name of the cache.String
getShortName()
ServerCacheStatistics
getStatistics(boolean reset)
Return statistics for the cache.void
periodicTrim(BackgroundExecutor executor)
void
put(Object id, Object value)
Put a value into the cache.void
putAll(Map<Object,Object> keyValues)
Put all the values in the cache.void
remove(Object id)
Remove an entry from the cache.void
runEviction()
Run the eviction based on Idle time, Time to live and LRU last access.int
size()
Return the number of elements in the cache.void
visit(MetricVisitor visitor)
Visit the metrics for the cache.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.ebean.cache.ServerCache
getAll, removeAll
-
-
-
-
Field Detail
-
BY_LAST_ACCESS
public static final DefaultServerCache.CompareByLastAccess BY_LAST_ACCESS
Compare by last access time (for LRU eviction).
-
-
Constructor Detail
-
DefaultServerCache
public DefaultServerCache(DefaultServerCacheConfig config)
-
-
Method Detail
-
periodicTrim
public void periodicTrim(BackgroundExecutor executor)
-
visit
public void visit(MetricVisitor visitor)
Description copied from interface:ServerCache
Visit the metrics for the cache.- Specified by:
visit
in interfaceServerCache
-
getStatistics
public ServerCacheStatistics getStatistics(boolean reset)
Description copied from interface:ServerCache
Return statistics for the cache.- Specified by:
getStatistics
in interfaceServerCache
- Parameters:
reset
- if true the statistics are reset.
-
getHitCount
public long getHitCount()
Return the count of get hits.
-
getMissCount
public long getMissCount()
Return the count of get misses.
-
getHitRatio
public int getHitRatio()
Description copied from interface:ServerCache
Return the hit ratio the cache is currently getting.- Specified by:
getHitRatio
in interfaceServerCache
-
getShortName
public String getShortName()
-
clear
public void clear()
Clear the cache.- Specified by:
clear
in interfaceServerCache
-
get
public Object get(Object id)
Return a value from the cache.- Specified by:
get
in interfaceServerCache
-
putAll
public void putAll(Map<Object,Object> keyValues)
Description copied from interface:ServerCache
Put all the values in the cache.- Specified by:
putAll
in interfaceServerCache
-
put
public void put(Object id, Object value)
Put a value into the cache.- Specified by:
put
in interfaceServerCache
-
remove
public void remove(Object id)
Remove an entry from the cache.- Specified by:
remove
in interfaceServerCache
-
size
public int size()
Return the number of elements in the cache.- Specified by:
size
in interfaceServerCache
-
runEviction
public void runEviction()
Run the eviction based on Idle time, Time to live and LRU last access.
-
-