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
public class RegionCacheAdapter extends StaticCache implements Cache, CacheLifecycleCallback
Class adapts calls to the de.hybris.platform.regioncache.CacheController class.
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 Constructor Description RegionCacheAdapter(Tenant tenant, CacheController controller)
-
Method Summary
All Methods Instance Methods Concrete 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)booleanequals(java.lang.Object obj)For sake of registering only one adapter in controllerAbstractCacheUnitgetAbstractCacheUnit(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()Gets total cache size for all regions.intgetMaxReachedSize()the maximum reached number of entries since creation of the cache.longgetMissCount()AbstractCacheUnitgetOrAddUnit(AbstractCacheUnit unit)Invokes de.hybris.platform.regioncache.CachegetController().getOrAddUnit()longgetRemoveCount()intgetSize()java.util.Set<? extends CacheStatisticsEntry>getStatistics(int upperBound, int lowerBound)FIXME: verifyTenantgetTenant()get the tenant this cache is created for.java.lang.StringgetTenantId()AbstractCacheUnitgetUnit(AbstractCacheUnit unit)inthashCode()voidinvalidate(java.lang.Object[] key, int invalidationType)Invokes de.hybris.platform.regioncache.CachegetController().invalidate()booleanisForceExclusiveComputation()We do not load in AbstractCacheUnit.load() (see its comment).booleanisStatsEmpty()Returnstrueif no cache statistics are collected.voidonAfterAdd(CacheKey key, java.lang.Object value, CacheRegion region)Executes after an object has been added to the cache.voidonAfterEviction(CacheKey key, java.lang.Object value, CacheRegion region)Executes after an object has been evicted from the cache.voidonAfterRemove(CacheKey key, java.lang.Object value, CacheRegion region)Executes after an object has been removed from the cache.voidonMissLoad(CacheKey key, java.lang.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.booleanstatsEnabled()Returnstrueif the statistics for the cache are enabled.java.lang.StringtoString()-
Methods inherited from class de.hybris.platform.cache.impl.StaticCache
clearRequestCache, clearStaticCache, getRequestCacheContent, getRequestCacheContentIfExists, getRequestCacheMap, getStaticCacheContent
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.cache.Cache
getRequestCacheContent, getRequestCacheContentIfExists, getStaticCacheContent
-
-
-
-
Constructor Detail
-
RegionCacheAdapter
public RegionCacheAdapter(Tenant tenant, CacheController controller)
-
-
Method Detail
-
getMaxAllowedSize
public int getMaxAllowedSize()
Gets total cache size for all regions.- Specified by:
getMaxAllowedSizein interfaceCache- Returns:
- the max allowed size
-
invalidate
public void invalidate(java.lang.Object[] key, int invalidationType)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
public AbstractCacheUnit getOrAddUnit(AbstractCacheUnit unit)
Invokes de.hybris.platform.regioncache.CachegetController().getOrAddUnit()- Specified by:
getOrAddUnitin interfaceCache
-
removeUnit
public void removeUnit(AbstractCacheUnit unit)
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
-
getTenant
public Tenant 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
public AbstractCacheUnit getUnit(AbstractCacheUnit unit) throws CacheRegionNotSpecifiedException
- Specified by:
getUnitin interfaceCache- Returns:
- null if no unit with the given key is in the cache
- Throws:
CacheRegionNotSpecifiedException
-
getStatistics
public java.util.Set<? extends CacheStatisticsEntry> getStatistics(int upperBound, int lowerBound)
FIXME: verify- 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(java.lang.String firstKeyElement, java.lang.String secondKeyElement, java.lang.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
public java.lang.String getTenantId()
- Specified by:
getTenantIdin interfaceCache
-
enableStats
public void enableStats(boolean enabled)
- Specified by:
enableStatsin interfaceCache
-
destroy
public void destroy()
Description copied from interface:CacheMethod called by tennant to free resources before object is finalized
-
onAfterAdd
public void onAfterAdd(CacheKey key, java.lang.Object value, CacheRegion region)
Description copied from interface:CacheLifecycleCallbackExecutes after an object has been added to the cache.- Specified by:
onAfterAddin interfaceCacheLifecycleCallback
-
onAfterRemove
public void onAfterRemove(CacheKey key, java.lang.Object value, CacheRegion region)
Description copied from interface:CacheLifecycleCallbackExecutes after an object has been removed from the cache.- Specified by:
onAfterRemovein interfaceCacheLifecycleCallback
-
onAfterEviction
public void onAfterEviction(CacheKey key, java.lang.Object value, CacheRegion region)
Description copied from interface:CacheLifecycleCallbackExecutes after an object has been evicted from the cache.- Specified by:
onAfterEvictionin interfaceCacheLifecycleCallback
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
For sake of registering only one adapter in controller- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
onMissLoad
public void onMissLoad(CacheKey key, java.lang.Object value, CacheRegion lruCacheRegion)
Description copied from interface:CacheLifecycleCallbackExecutes after an object has been loaded but not added to the cache.- Specified by:
onMissLoadin interfaceCacheLifecycleCallback
-
-