Package de.hybris.platform.cache
Interface Cache
-
- All Superinterfaces:
InvalidationTarget
- All Known Implementing Classes:
DefaultCache,RegionCacheAdapter
public interface Cache extends InvalidationTarget
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCACHEKEY_C2LMANAGERstatic java.lang.StringCACHEKEY_CUSTOMstatic java.lang.StringCACHEKEY_ENTITYstatic java.lang.StringCACHEKEY_ENTITYISALIVEstatic java.lang.StringCACHEKEY_FINDstatic java.lang.StringCACHEKEY_FLEXSEARCHstatic java.lang.StringCACHEKEY_HJMPstatic java.lang.StringCACHEKEY_JALOITEMCACHEstatic java.lang.StringCACHEKEY_JALOITEMDATAstatic java.lang.StringCACHEKEY_JALOTYPEstatic java.lang.StringCONFIG_CACHE_MAINstatic java.lang.StringCONFIG_CACHE_SHAREDstatic java.lang.StringCONFIG_CONCURRENCY_LEVELstatic java.lang.StringCONFIG_EVICTION_POLICYstatic java.lang.StringCONFIG_FORCE_EXCLUSIVE_CALCULATIONstatic intDEFAULT_CACHE_MAINstatic booleanDEFAULT_CACHE_SHAREDstatic intLIMIT_CACHE_MAIN
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()voidclearStats()Clears the collected cache statistics.voiddestroy()Method called by tennant to free resources before object is finalizedvoidenableStats(boolean enabled)AbstractCacheUnitgetAbstractCacheUnit(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 elementslonggetAddCount()longgetGetCount()intgetMaxAllowedSize()The upper limit for the cache.intgetMaxReachedSize()the maximum reached number of entries since creation of the cache.longgetMissCount()AbstractCacheUnitgetOrAddUnit(AbstractCacheUnit unit)gets value stored in the cache or loads it.
Throws exception wrapped into RuntimeExceptionlonggetRemoveCount()<T> TgetRequestCacheContent(SingletonCreator.Creator<T> creator)<T> TgetRequestCacheContentIfExists(SingletonCreator.Creator<T> creator)intgetSize()<T> TgetStaticCacheContent(SingletonCreator.Creator<T> creator)java.util.Set<? extends CacheStatisticsEntry>getStatistics(int upperBound, int lowerBound)Returns asSetthe collected cache statistics.TenantgetTenant()get the tenant this cache is created for.java.lang.StringgetTenantId()AbstractCacheUnitgetUnit(AbstractCacheUnit unit)voidinvalidate(java.lang.Object[] key, int invalidationType)execute invalidation (not delayed to transaction end)booleanisForceExclusiveComputation()checks if AbstractCacheUnit should synchronize load function.booleanisStatsEmpty()Returnstrueif no cache statistics are collected.voidremoveUnit(AbstractCacheUnit unit)Removes a cache unit from this cache.voidsetEnabled(boolean enabled)enables/disables the cache.voidsetStatsEnabled(boolean enabled)Enables or disables the cache statistics.booleanstatsEnabled()Returnstrueif the statistics for the cache are enabled.
-
-
-
Field Detail
-
CACHEKEY_HJMP
static final java.lang.String CACHEKEY_HJMP
-
CACHEKEY_ENTITY
static final java.lang.String CACHEKEY_ENTITY
-
CACHEKEY_FIND
static final java.lang.String CACHEKEY_FIND
-
CACHEKEY_FLEXSEARCH
static final java.lang.String CACHEKEY_FLEXSEARCH
-
CACHEKEY_ENTITYISALIVE
static final java.lang.String CACHEKEY_ENTITYISALIVE
-
CACHEKEY_JALOITEMDATA
static final java.lang.String CACHEKEY_JALOITEMDATA
-
CACHEKEY_JALOTYPE
static final java.lang.String CACHEKEY_JALOTYPE
-
CACHEKEY_JALOITEMCACHE
static final java.lang.String CACHEKEY_JALOITEMCACHE
-
CACHEKEY_CUSTOM
static final java.lang.String CACHEKEY_CUSTOM
-
CACHEKEY_C2LMANAGER
static final java.lang.String CACHEKEY_C2LMANAGER
-
CONFIG_CACHE_MAIN
static final java.lang.String CONFIG_CACHE_MAIN
- See Also:
- Constant Field Values
-
CONFIG_CACHE_SHARED
static final java.lang.String CONFIG_CACHE_SHARED
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_SHARED
static final boolean DEFAULT_CACHE_SHARED
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_MAIN
static final int DEFAULT_CACHE_MAIN
- See Also:
- Constant Field Values
-
LIMIT_CACHE_MAIN
static final int LIMIT_CACHE_MAIN
- See Also:
- Constant Field Values
-
CONFIG_CONCURRENCY_LEVEL
static final java.lang.String CONFIG_CONCURRENCY_LEVEL
- See Also:
- Constant Field Values
-
CONFIG_EVICTION_POLICY
static final java.lang.String CONFIG_EVICTION_POLICY
- See Also:
- Constant Field Values
-
CONFIG_FORCE_EXCLUSIVE_CALCULATION
static final java.lang.String CONFIG_FORCE_EXCLUSIVE_CALCULATION
- See Also:
- Constant Field Values
-
-
Method Detail
-
setEnabled
void setEnabled(boolean enabled)
enables/disables the cache.- Parameters:
enabled-truefor enabling the cache,falseotherwise.
-
getOrAddUnit
AbstractCacheUnit getOrAddUnit(AbstractCacheUnit unit)
gets value stored in the cache or loads it.
Throws exception wrapped into RuntimeException
-
getUnit
AbstractCacheUnit getUnit(AbstractCacheUnit unit)
- Returns:
- null if no unit with the given key is in the cache
- Throws:
CacheRegionNotSpecifiedException
-
isForceExclusiveComputation
boolean isForceExclusiveComputation()
checks if AbstractCacheUnit should synchronize load function.
-
clear
void clear()
-
removeUnit
void removeUnit(AbstractCacheUnit unit)
Removes a cache unit from this cache.- Parameters:
unit- the unit to be removed. note that the same of any unit with the same key is removed.
-
invalidate
void invalidate(java.lang.Object[] key, int invalidationType)execute invalidation (not delayed to transaction end)- Specified by:
invalidatein interfaceInvalidationTarget- Parameters:
key- may be an incomplete key, for group invalidation
-
getAbstractCacheUnit
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
-
clearStats
void clearStats()
Clears the collected cache statistics.
-
statsEnabled
boolean statsEnabled()
Returnstrueif the statistics for the cache are enabled. This can be modified with the methodsetStatsEnabled(boolean). Collecting the statistics is very memory intensive - useclearStats()frequently.- Returns:
falseotherwise.
-
setStatsEnabled
void setStatsEnabled(boolean enabled)
Enables or disables the cache statistics.- Parameters:
enabled-truefor enabling the statistics
-
enableStats
void enableStats(boolean enabled)
-
isStatsEmpty
boolean isStatsEmpty()
Returnstrueif no cache statistics are collected. addToStatistics(Object[], boolean) was not called yet)- Returns:
falseotherwise
-
getStatistics
java.util.Set<? extends CacheStatisticsEntry> getStatistics(int upperBound, int lowerBound)
Returns asSetthe collected cache statistics. Each set entry is aDefaultCacheStatisticsEntry. With the parametersupperBoundandlowerBounda reduced Set will be returned.DefaultCacheStatisticsEntry.getFactor()must be betweenupperBoundandlowerBound.- Parameters:
upperBound- 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.- Returns:
- a Set with
DefaultCacheStatisticsEntry.
-
getMaxAllowedSize
int getMaxAllowedSize()
The upper limit for the cache. this normally equals the setting 'cache.main' and is the number of cache entries that are allowed until the cache mechanism will remove the least recently used entries before adding new ones.- Returns:
- the max allowed size
-
getMaxReachedSize
int getMaxReachedSize()
the maximum reached number of entries since creation of the cache. this is only reseted if Cache#clearCache() is called.
-
getSize
int getSize()
-
getAddCount
long getAddCount()
- Returns:
- how many entities where added to the cache since creation of the cache. This is reseted by calling
clear()orclearStats().
-
getRemoveCount
long getRemoveCount()
- Returns:
- how many entities where removed from the cache since creation of the cache. This is reseted by calling
clear()orclearStats().
-
getGetCount
long getGetCount()
- Returns:
- how many entities where requested from the cache since creation of the cache. This is reseted by calling
clear()orclearStats().
-
getMissCount
long getMissCount()
- Returns:
- how many entities where requested from the cache but wasn't in the cache (yet) since creation of the
cache. This is reseted by calling
clear()orclearStats().
-
destroy
void destroy()
Method called by tennant to free resources before object is finalized
-
getTenant
Tenant getTenant()
get the tenant this cache is created for. The hybris 'internal' cache (Tenant.getCache()always has a tenant, but it is possible to create your own Cache without assigning to a tenant.- Returns:
- the tenant or null if no tenant set
-
getTenantId
java.lang.String getTenantId()
-
getStaticCacheContent
<T> T getStaticCacheContent(SingletonCreator.Creator<T> creator)
-
getRequestCacheContent
<T> T getRequestCacheContent(SingletonCreator.Creator<T> creator)
-
getRequestCacheContentIfExists
<T> T getRequestCacheContentIfExists(SingletonCreator.Creator<T> creator)
-
-