Package de.hybris.platform.cache.impl
Class RegionCacheAdapter
java.lang.Object
de.hybris.platform.cache.impl.StaticCache
de.hybris.platform.cache.impl.RegionCacheAdapter
- All Implemented Interfaces:
Cache,InvalidationTarget,CacheLifecycleCallback
Class adapts calls to the de.hybris.platform.regioncache.CacheController class.
It is used by AbstractCacheUnit to perform cache operations on regioncache implementations.
It is used by AbstractCacheUnit to perform cache operations on regioncache implementations.
-
Field Summary
Fields inherited from interface de.hybris.platform.cache.Cache
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidClears the collected cache statistics.voiddestroy()Method called by tennant to free resources before object is finalizedvoidenableStats(boolean enabled) booleanFor sake of registering only one adapter in controllergetAbstractCacheUnit(String firstKeyElement, String secondKeyElement, String thirdKeyElement, PK fourthKeyElement) for performance optimizations: get a existing cache unit; the key of the cache unit must consist of exactly three elementslonglongintGets total cache size for all regions.intthe maximum reached number of entries since creation of the cache.longInvokes de.hybris.platform.regioncache.CachegetController().getOrAddUnit()longintgetSize()Set<? extends CacheStatisticsEntry>getStatistics(int upperBound, int lowerBound) Returns asSetthe collected cache statistics.get the tenant this cache is created for.getUnit(AbstractCacheUnit unit) inthashCode()voidinvalidate(Object[] key, int invalidationType) Invokes de.hybris.platform.regioncache.CachegetController().invalidate()booleanWe do not load in AbstractCacheUnit.load() (see its comment).booleanReturnstrueif no cache statistics are collected.voidonAfterAdd(CacheKey key, Object value, CacheRegion region) Executes after an object has been added to the cache.voidonAfterEviction(CacheKey key, Object value, CacheRegion region) Executes after an object has been evicted from the cache.voidonAfterRemove(CacheKey key, Object value, CacheRegion region) Executes after an object has been removed from the cache.voidonMissLoad(CacheKey key, Object value, CacheRegion lruCacheRegion) Executes after an object has been loaded but not added to the cache.voidremoveUnit(AbstractCacheUnit unit) Removes value from the cachevoidsetEnabled(boolean enabled) enables/disables the cache.voidsetStatsEnabled(boolean on) Enables or disables the cache statistics.booleanReturnstrueif the statistics for the cache are enabled.toString()Methods inherited from class de.hybris.platform.cache.impl.StaticCache
clearRequestCache, clearStaticCache, getRequestCacheContent, getRequestCacheContentIfExists, getRequestCacheMap, getStaticCacheContentMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface de.hybris.platform.cache.Cache
getRequestCacheContent, getRequestCacheContentIfExists, getStaticCacheContent
-
Constructor Details
-
RegionCacheAdapter
-
-
Method Details
-
getMaxAllowedSize
public int getMaxAllowedSize()Gets total cache size for all regions.- Specified by:
getMaxAllowedSizein interfaceCache- Returns:
- the max allowed size
-
invalidate
Invokes de.hybris.platform.regioncache.CachegetController().invalidate()- Specified by:
invalidatein interfaceCache- Specified by:
invalidatein interfaceInvalidationTarget- Parameters:
key- may be an incomplete key, for group invalidation
-
getOrAddUnit
Invokes de.hybris.platform.regioncache.CachegetController().getOrAddUnit()- Specified by:
getOrAddUnitin interfaceCache
-
removeUnit
Removes value from the cache- Specified by:
removeUnitin interfaceCache- Parameters:
unit- the unit to be removed. note that the same of any unit with the same key is removed.
-
isForceExclusiveComputation
public boolean isForceExclusiveComputation()We do not load in AbstractCacheUnit.load() (see its comment). This is affecting AbstractCacheUnit.compute(). We have to support old cache flag for this since each cache region is configured separately.- Specified by:
isForceExclusiveComputationin interfaceCache
-
clear
public void clear() -
getTenant
Description copied from interface:Cacheget 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. -
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:Cacheenables/disables the cache.- Specified by:
setEnabledin interfaceCache- Parameters:
enabled-truefor enabling the cache,falseotherwise.
-
getAddCount
public long getAddCount()- Specified by:
getAddCountin interfaceCache- Returns:
- how many entities where added to the cache since creation of the cache. This is reseted by calling
Cache.clear()orCache.clearStats().
-
getRemoveCount
public long getRemoveCount()- Specified by:
getRemoveCountin interfaceCache- Returns:
- how many entities where removed from the cache since creation of the cache. This is reseted by calling
Cache.clear()orCache.clearStats().
-
getGetCount
public long getGetCount()- Specified by:
getGetCountin interfaceCache- Returns:
- how many entities where requested from the cache since creation of the cache. This is reseted by calling
Cache.clear()orCache.clearStats().
-
getMissCount
public long getMissCount()- Specified by:
getMissCountin interfaceCache- 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
Cache.clear()orCache.clearStats().
-
statsEnabled
public boolean statsEnabled()Description copied from interface:CacheReturnstrueif the statistics for the cache are enabled. This can be modified with the methodCache.setStatsEnabled(boolean). Collecting the statistics is very memory intensive - useCache.clearStats()frequently.- Specified by:
statsEnabledin interfaceCache- Returns:
falseotherwise.
-
setStatsEnabled
public void setStatsEnabled(boolean on) Description copied from interface:CacheEnables or disables the cache statistics.- Specified by:
setStatsEnabledin interfaceCache- Parameters:
on-truefor enabling the statistics
-
clearStats
public void clearStats()Description copied from interface:CacheClears the collected cache statistics.- Specified by:
clearStatsin interfaceCache
-
isStatsEmpty
public boolean isStatsEmpty()Description copied from interface:CacheReturnstrueif no cache statistics are collected. addToStatistics(Object[], boolean) was not called yet)- Specified by:
isStatsEmptyin interfaceCache- Returns:
falseotherwise
-
getMaxReachedSize
public int getMaxReachedSize()Description copied from interface:Cachethe maximum reached number of entries since creation of the cache. this is only reseted if Cache#clearCache() is called.- Specified by:
getMaxReachedSizein interfaceCache
-
getUnit
- Specified by:
getUnitin interfaceCache- Returns:
- null if no unit with the given key is in the cache
- Throws:
CacheRegionNotSpecifiedException
-
getStatistics
Description copied from interface:CacheReturns asSetthe collected cache statistics. Each set entry is aDefaultCacheStatisticsEntry. With the parametersupperBoundandlowerBounda reduced Set will be returned.DefaultCacheStatisticsEntry.getFactor()must be betweenupperBoundandlowerBound.- Specified by:
getStatisticsin interfaceCache- 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.
-
getAbstractCacheUnit
public AbstractCacheUnit getAbstractCacheUnit(String firstKeyElement, String secondKeyElement, String thirdKeyElement, PK fourthKeyElement) Description copied from interface:Cachefor performance optimizations: get a existing cache unit; the key of the cache unit must consist of exactly three elements- Specified by:
getAbstractCacheUnitin interfaceCache
-
getTenantId
- Specified by:
getTenantIdin interfaceCache
-
enableStats
public void enableStats(boolean enabled) - Specified by:
enableStatsin interfaceCache
-
getSize
public int getSize() -
destroy
public void destroy()Description copied from interface:CacheMethod called by tennant to free resources before object is finalized -
onAfterAdd
Description copied from interface:CacheLifecycleCallbackExecutes after an object has been added to the cache.- Specified by:
onAfterAddin interfaceCacheLifecycleCallback
-
onAfterRemove
Description copied from interface:CacheLifecycleCallbackExecutes after an object has been removed from the cache.- Specified by:
onAfterRemovein interfaceCacheLifecycleCallback
-
onAfterEviction
Description copied from interface:CacheLifecycleCallbackExecutes after an object has been evicted from the cache.- Specified by:
onAfterEvictionin interfaceCacheLifecycleCallback
-
hashCode
public int hashCode() -
equals
For sake of registering only one adapter in controller -
toString
-
onMissLoad
Description copied from interface:CacheLifecycleCallbackExecutes after an object has been loaded but not added to the cache.- Specified by:
onMissLoadin interfaceCacheLifecycleCallback
-