public final class DefaultCache extends StaticCache implements Cache
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
tenantId |
CACHEKEY_C2LMANAGER, CACHEKEY_CUSTOM, CACHEKEY_ENTITY, CACHEKEY_ENTITYISALIVE, CACHEKEY_FIND, CACHEKEY_FLEXSEARCH, CACHEKEY_HJMP, CACHEKEY_JALOITEMCACHE, CACHEKEY_JALOITEMDATA, CACHEKEY_JALOTYPE, CONFIG_CACHE_MAIN, CONFIG_CACHE_SHARED, CONFIG_CONCURRENCY_LEVEL, CONFIG_EVICTION_POLICY, CONFIG_FORCE_EXCLUSIVE_CALCULATION, DEFAULT_CACHE_MAIN, DEFAULT_CACHE_SHARED, LIMIT_CACHE_MAIN| Constructor and Description |
|---|
DefaultCache(Tenant tenant,
int maxCacheSize)
Creates a new cache.
|
DefaultCache(Tenant tenant,
int maxCacheSize,
boolean forceExclComp)
Creates a new cache.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
clearStats()
Clears the collected cache statistics.
|
void |
destroy()
Method called by tennant to free resources before object is finalized
|
void |
enableStats(boolean enabled)
Enables or disables the cache statistics.
|
AbstractCacheUnit |
getAbstractCacheUnit(java.lang.String firstKeyElement,
java.lang.String secondKeyElement,
java.lang.String thirdKeyElement,
PK fourthKeyElement)
for performance optimizations: get a existing cache unit; the key of the cache unit must consist of exactly three
elements
|
long |
getAddCount() |
long |
getGetCount() |
int |
getMaxAllowedSize()
The upper limit for the cache.
|
int |
getMaxReachedSize()
the maximum reached number of entries since creation of the cache.
|
long |
getMissCount() |
AbstractCacheUnit |
getOrAddUnit(AbstractCacheUnit unit)
gets value stored in the cache or loads it.
Throws exception wrapped into RuntimeException |
AbstractCacheUnit |
getOrAddUnitInternal(AbstractCacheUnit unit,
java.util.concurrent.locks.ReadWriteLock rwLock) |
long |
getRemoveCount() |
int |
getSize()
the current size of the internal cache (in 'entries')
|
java.util.Set |
getStatistics(int upperBound,
int lowerBound)
Returns as
Set the collected cache statistics. |
Tenant |
getTenant()
get the tenant this cache is created for.
|
java.lang.String |
getTenantId() |
AbstractCacheUnit |
getUnit(AbstractCacheUnit unit) |
CacheMap |
internalCreateMapInstance(int max) |
static CacheMap |
internalCreateMapInstanceStatic(Tenant tenant,
int max) |
void |
invalidate(java.lang.Object[] key,
int invalidationType)
execute invalidation (not delayed to transaction end)
|
boolean |
isForceExclusiveComputation()
Tells
AbstractCacheUnit whether value computation should be exclusive (synchronized) or not. |
static boolean |
isMultiPathKey(java.lang.Object[] key)
Tells whether the given key array actually contains multiple keys.
|
boolean |
isStatsEmpty()
Returns
true if no cache statistics are collected. |
static java.lang.String |
keyToString(java.lang.Object[] key) |
void |
removeUnit(AbstractCacheUnit unit)
Removes a cache unit from this cache.
|
void |
setEnabled(boolean enabled)
enables/disables the cache.
|
void |
setStatsEnabled(boolean enabled)
Enables or disables the cache statistics.
|
boolean |
statsEnabled()
Returns
true if the statistics for the cache are enabled. |
static java.util.List<java.lang.Object[]> |
toSingleKey(java.lang.Object[] key)
Transforms a given key into one or more single keys.
|
java.lang.String |
toString()
prints out some more or less useful information about this cache instance (like the maximum allowed size)
|
clearRequestCache, clearStaticCache, getRequestCacheContent, getRequestCacheContentIfExists, getRequestCacheMap, getStaticCacheContentclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetRequestCacheContent, getRequestCacheContentIfExists, getStaticCacheContentpublic DefaultCache(Tenant tenant, int maxCacheSize)
tenant - the cache ownermaxCacheSize - the max cache sizepublic DefaultCache(Tenant tenant, int maxCacheSize, boolean forceExclComp)
tenant - the cache ownermaxCacheSize - the max cache sizeforceExclComp - allows to specify CONFIG_FORCE_EXCLUSIVE_CALCULATION manually instead of reading it from tenant
configurationpublic CacheMap internalCreateMapInstance(int max)
public static CacheMap internalCreateMapInstanceStatic(Tenant tenant, int max)
public void destroy()
Cachepublic Tenant getTenant()
Tenant.getCache() always has a
tenant, but it is possible to create your own Cache without assigning to a tenant.public java.lang.String getTenantId()
getTenantId in interface Cachepublic java.lang.String toString()
toString in class java.lang.Objectpublic void setEnabled(boolean enabled)
CachesetEnabled in interface Cacheenabled - true for enabling the cache, false otherwise.public int getSize()
public int getMaxAllowedSize()
getMaxAllowedSize in interface Cachepublic int getMaxReachedSize()
getMaxReachedSize in interface Cachepublic static boolean isMultiPathKey(java.lang.Object[] key)
Multi-key : [ [ foo, bar, 1 ] [ x, y, z ] ] Single key : [ foo, bar, 1 ]
toSingleKey(Object[])public static java.util.List<java.lang.Object[]> toSingleKey(java.lang.Object[] key)
isMultiPathKey(Object[])public void removeUnit(AbstractCacheUnit unit)
removeUnit in interface Cacheunit - the unit to be removed. note that the same of any unit with the same key is removed.public AbstractCacheUnit getUnit(AbstractCacheUnit unit)
public AbstractCacheUnit getOrAddUnit(AbstractCacheUnit unit)
CachegetOrAddUnit in interface Cachepublic AbstractCacheUnit getOrAddUnitInternal(AbstractCacheUnit unit, java.util.concurrent.locks.ReadWriteLock rwLock)
public void invalidate(java.lang.Object[] key,
int invalidationType)
invalidate in interface Cacheinvalidate in interface InvalidationTargetkey - may be an incomplete key, for group invalidationpublic AbstractCacheUnit getAbstractCacheUnit(java.lang.String firstKeyElement, java.lang.String secondKeyElement, java.lang.String thirdKeyElement, PK fourthKeyElement)
getAbstractCacheUnit in interface Cachepublic long getAddCount()
getAddCount in interface Cacheclear() or clearStats().public long getRemoveCount()
getRemoveCount in interface Cacheclear() or clearStats().public long getGetCount()
getGetCount in interface Cacheclear() or clearStats().public long getMissCount()
getMissCount in interface Cacheclear() or clearStats().public boolean statsEnabled()
true if the statistics for the cache are enabled. This can be modified with the method
enableStats(boolean). Collecting the statistics is very memory intensive - use clearStats()
frequently.statsEnabled in interface Cachefalse otherwise.public void enableStats(boolean enabled)
enableStats in interface Cacheenabled - true for enabling the statisticspublic void clearStats()
clearStats in interface Cachepublic boolean isStatsEmpty()
true if no cache statistics are collected. (addToStatistics(Object[], boolean) was
not called yet)isStatsEmpty in interface Cachefalse otherwisepublic boolean isForceExclusiveComputation()
AbstractCacheUnit whether value computation should be exclusive (synchronized) or not.isForceExclusiveComputation in interface Cachepublic java.util.Set getStatistics(int upperBound,
int lowerBound)
Set the collected cache statistics. Each set entry is a CacheStatisticsEntry. With the
parameters upperBound and lowerBound a reduced Set will be returned.
CacheStatisticsEntry.getFactor() must be between upperBound and lowerBound.getStatistics in interface CacheupperBound - the upper bound for the returned set. Each entry factor is equal or less.lowerBound - the lower bound the the returned set. Each entry factor is greater or equal.CacheStatisticsEntry.public static java.lang.String keyToString(java.lang.Object[] key)
public void setStatsEnabled(boolean enabled)
CachesetStatsEnabled in interface Cacheenabled - true for enabling the statisticsCopyright © 2018 SAP SE. All Rights Reserved.