Package org.thymeleaf.cache
Class StandardCache<K,V>
- java.lang.Object
-
- org.thymeleaf.cache.StandardCache<K,V>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classStandardCache.CacheDataContainer<K,V>(package private) static classStandardCache.CacheEntry<V>
-
Field Summary
Fields Modifier and Type Field Description private StandardCache.CacheDataContainer<K,V>dataContainerprivate booleanenableCountersprivate ICacheEntryValidityChecker<? super K,? super V>entryValidityCheckerprivate java.util.concurrent.atomic.AtomicLonggetCountprivate java.util.concurrent.atomic.AtomicLonghitCountprivate longlastExecutionprivate org.slf4j.Loggerloggerprivate intmaxSizeprivate java.util.concurrent.atomic.AtomicLongmissCountprivate java.lang.Stringnameprivate java.util.concurrent.atomic.AtomicLongputCountprivate static java.lang.StringREPORT_FORMATprivate static longREPORT_INTERVALprivate booleantraceExecutionprivate booleanuseSoftReferences
-
Constructor Summary
Constructors Constructor Description StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, int maxSize, org.slf4j.Logger logger)StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, int maxSize, ICacheEntryValidityChecker<? super K,? super V> entryValidityChecker, org.slf4j.Logger logger)StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, int maxSize, ICacheEntryValidityChecker<? super K,? super V> entryValidityChecker, org.slf4j.Logger logger, boolean enableCounters)StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, org.slf4j.Logger logger)StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, ICacheEntryValidityChecker<? super K,? super V> entryValidityChecker, org.slf4j.Logger logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear the entire cache.voidclearKey(K key)Clears a specific entry in the cache.Vget(K key)Retrieve a value from the cache.Vget(K key, ICacheEntryValidityChecker<? super K,? super V> validityChecker)Retrieve a value from the cache, using the specified validity checker to ensure the entry is still valid.longgetGetCount()longgetHitCount()doublegetHitRatio()intgetMaxSize()longgetMissCount()doublegetMissRatio()java.lang.StringgetName()longgetPutCount()booleangetUseSoftReferences()booleanhasMaxSize()private voidincrementReportEntity(java.util.concurrent.atomic.AtomicLong entity)java.util.Set<K>keySet()Returns all the keys contained in this cache.private voidoutputReportIfNeeded()voidput(K key, V value)Insert a new value into the cache.intsize()
-
-
-
Field Detail
-
REPORT_INTERVAL
private static final long REPORT_INTERVAL
- See Also:
- Constant Field Values
-
REPORT_FORMAT
private static final java.lang.String REPORT_FORMAT
- See Also:
- Constant Field Values
-
lastExecution
private volatile long lastExecution
-
name
private final java.lang.String name
-
useSoftReferences
private final boolean useSoftReferences
-
maxSize
private final int maxSize
-
dataContainer
private final StandardCache.CacheDataContainer<K,V> dataContainer
-
entryValidityChecker
private final ICacheEntryValidityChecker<? super K,? super V> entryValidityChecker
-
traceExecution
private final boolean traceExecution
-
enableCounters
private final boolean enableCounters
-
logger
private final org.slf4j.Logger logger
-
getCount
private final java.util.concurrent.atomic.AtomicLong getCount
-
putCount
private final java.util.concurrent.atomic.AtomicLong putCount
-
hitCount
private final java.util.concurrent.atomic.AtomicLong hitCount
-
missCount
private final java.util.concurrent.atomic.AtomicLong missCount
-
-
Constructor Detail
-
StandardCache
public StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, org.slf4j.Logger logger)
-
StandardCache
public StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, ICacheEntryValidityChecker<? super K,? super V> entryValidityChecker, org.slf4j.Logger logger)
-
StandardCache
public StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, int maxSize, org.slf4j.Logger logger)
-
StandardCache
public StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, int maxSize, ICacheEntryValidityChecker<? super K,? super V> entryValidityChecker, org.slf4j.Logger logger)
-
StandardCache
public StandardCache(java.lang.String name, boolean useSoftReferences, int initialCapacity, int maxSize, ICacheEntryValidityChecker<? super K,? super V> entryValidityChecker, org.slf4j.Logger logger, boolean enableCounters)
-
-
Method Detail
-
put
public void put(K key, V value)
Description copied from interface:ICacheInsert a new value into the cache.
-
get
public V get(K key, ICacheEntryValidityChecker<? super K,? super V> validityChecker)
Description copied from interface:ICacheRetrieve a value from the cache, using the specified validity checker to ensure the entry is still valid. If the cache already has a default validity checker, this method should override this setting and use the one specified instead.
-
keySet
public java.util.Set<K> keySet()
Returns all the keys contained in this cache. Note this method might return keys for entries that are already invalid, so the result of calling
get(Object)for these keys might benull.
-
clear
public void clear()
Description copied from interface:ICacheClear the entire cache.
-
clearKey
public void clearKey(K key)
Description copied from interface:ICacheClears a specific entry in the cache.
-
getName
public java.lang.String getName()
-
hasMaxSize
public boolean hasMaxSize()
-
getMaxSize
public int getMaxSize()
-
getUseSoftReferences
public boolean getUseSoftReferences()
-
size
public int size()
-
getPutCount
public long getPutCount()
-
getGetCount
public long getGetCount()
-
getHitCount
public long getHitCount()
-
getMissCount
public long getMissCount()
-
getHitRatio
public double getHitRatio()
-
getMissRatio
public double getMissRatio()
-
incrementReportEntity
private void incrementReportEntity(java.util.concurrent.atomic.AtomicLong entity)
-
outputReportIfNeeded
private void outputReportIfNeeded()
-
-