K
- the type of the keys of the cacheV
- the type of the values of the cachepublic abstract class AbstractCache<K,V> extends GenericService
Created: August 21 2013
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string from source code control system.
|
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
AbstractCache() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
contains(java.lang.Object pKey)
Checks for the presence of the object with the specified key, without
invoking the CacheAdapter.
|
boolean |
contains(java.lang.Object[] pKeys)
Returns false unless all specified keys refer to objects in the cache.
|
abstract void |
flush()
Flushes all entries from the cache, leaving it empty.
|
abstract V |
get(java.lang.Object pKey)
Searches the cache for the object with the specified key.
|
abstract java.lang.Object[] |
get(java.lang.Object[] pKeys)
Searches the cache for the objects with the specified keys.
|
abstract V |
get(java.lang.Object pKey,
boolean pCreate)
Searches the cache for the object with the specified key.
|
abstract int |
getAccessCount()
Returns the total number of accesses
|
abstract java.util.Iterator<V> |
getAllElements()
Returns all elements in this Cache.
|
abstract java.util.Iterator<K> |
getAllKeys()
Returns all elements in this Cache.
|
CacheAdapter |
getCacheAdapter()
The Adapter used to create entries in the cache
|
atg.service.cache.CacheRemovalListener |
getCacheRemovalListener()
The CacheRemovalListener notified when objects are removed from this cache
|
abstract int |
getHitCount()
Returns the number of cache hits
|
double |
getHitRatio()
Returns the number of cache hits / total number of cache accesses
|
int |
getMaximumCacheEntries()
Returns the maximum number of elements in the cache.
0 = Cache nothing, but continue to get objects from the CacheAdapter -1 = Unlimited |
int |
getMaximumCacheSize()
Returns the maximum memory size of the cache.
|
long |
getMaximumEntryLifetime()
Returns the maximum number of msec that an entry will live in the cache.
0 = Cache nothing, but continue to get objects from the CacheAdapter -1 = Unlimited |
int |
getMaximumEntrySize()
Returns the maximum memory size of a single entry in the cache.
|
abstract int |
getNumCacheEntries()
Returns the number of entries currently in the cache
|
int |
getSize()
Returns the number of entries currently in the cache
|
abstract int |
getTimeoutCount()
Returns the number of times entries were invalidated because they
were out-of-date.
|
double |
getUsedCapacity()
Returns the ratio of cache entries to maximum cache entries.
|
abstract int |
getUsedMemory()
Returns the amount of memory taken up by the entries in the cache
(includes keys).
|
double |
getUsedMemoryCapacity()
Returns the ratio of memory size to maximum memory size
|
abstract java.util.Iterator<K> |
getValidKeysOrdered(boolean pLatestFirst)
Returns all elements in this Cache ordered by entry creation time.
|
protected boolean |
hasOtherwiseExpired(K pKey,
V pValue)
Provide an extension point for adding additional expiration
logic.
|
boolean |
isCaching()
Whether we are actively caching at all.
|
protected boolean |
isExpiredValueStillGood(K pKey,
V pValue)
Return whether the expired value is still good.
|
abstract void |
put(K pKey,
V pValue)
Put the value pValue in the cache and associate it with pKey.
|
abstract boolean |
remove(java.lang.Object pKey)
Invalidates the entry with the given key.
|
void |
setCacheAdapter(CacheAdapter pAdapter)
The Adapter used to create entries in the cache
|
void |
setCacheRemovalListener(atg.service.cache.CacheRemovalListener pRemovalListener)
The CacheRemovalListener notified when objects are removed from this cache
|
void |
setMaximumCacheEntries(int pMaximumCacheEntries)
Sets the maximum number of elements in the cache.
|
void |
setMaximumCacheSize(int pMaximumCacheSize)
Sets the maximum memory size of the cache.
|
void |
setMaximumEntryLifetime(long pMaximumEntryLifetime)
Sets the maximum number of msec that an entry will live in the cache.
0 = Cache nothing, but continue to get objects from the CacheAdapter -1 = Unlimited |
void |
setMaximumEntrySize(int pMaximumEntrySize)
Sets the maximum memory size of a single entry in the cache.
|
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static final java.lang.String CLASS_VERSION
public CacheAdapter getCacheAdapter()
public void setCacheAdapter(CacheAdapter pAdapter)
pAdapter
- the adapter to set.public atg.service.cache.CacheRemovalListener getCacheRemovalListener()
public void setCacheRemovalListener(atg.service.cache.CacheRemovalListener pRemovalListener)
public int getMaximumCacheEntries()
public void setMaximumCacheEntries(int pMaximumCacheEntries)
public int getMaximumCacheSize()
public void setMaximumCacheSize(int pMaximumCacheSize)
public int getMaximumEntrySize()
public void setMaximumEntrySize(int pMaximumEntrySize)
public long getMaximumEntryLifetime()
public void setMaximumEntryLifetime(long pMaximumEntryLifetime)
public boolean isCaching()
public abstract boolean contains(java.lang.Object pKey)
pKey
- the key to check for in our cachepublic boolean contains(java.lang.Object[] pKeys)
pKeys
- the keys to check for in our cache.public abstract V get(java.lang.Object pKey) throws java.lang.Exception
pKey
- the key whose value should be returned.java.lang.Exception
- on an error (such an error occurring
when a CacheAdapter fetches a missing value).public abstract V get(java.lang.Object pKey, boolean pCreate) throws java.lang.Exception
pKey
- the key of the value to fetchpCreate
- whether to create a missing value.java.lang.Exception
- on an error (such an error occurring
when a CacheAdapter fetches a missing value).public abstract java.lang.Object[] get(java.lang.Object[] pKeys) throws java.lang.Exception
pKeys
- the keys whose values should be returned.java.lang.Exception
- on an error (such an error occurring
when a CacheAdapter fetches a missing value).protected boolean isExpiredValueStillGood(K pKey, V pValue)
pKey
- the key the corresponds to the valuepValue
- the value to checkprotected boolean hasOtherwiseExpired(K pKey, V pValue)
pKey
- the key of the possibly expired cache entrypValue
- pValue the value of possibly expired cache entrypublic abstract void put(K pKey, V pValue)
pKey
- the key to put in the cache.pValue
- the value to put in the cache associated with pKey.public abstract boolean remove(java.lang.Object pKey)
pKey
- the key of the entry to remove.public abstract void flush()
public int getSize()
public abstract int getNumCacheEntries()
public double getUsedCapacity()
public abstract int getUsedMemory()
public abstract int getAccessCount()
public abstract int getHitCount()
public double getHitRatio()
public abstract int getTimeoutCount()
public abstract java.util.Iterator<V> getAllElements()
public abstract java.util.Iterator<K> getAllKeys()
public double getUsedMemoryCapacity()
public abstract java.util.Iterator<K> getValidKeysOrdered(boolean pLatestFirst)
pLatestFirst
- whether to return the latest first.