Class EHCacheRegion
java.lang.Object
de.hybris.platform.regioncache.region.impl.EHCacheRegion
- All Implemented Interfaces:
CacheRegion
- Direct Known Subclasses:
WebhookDeletedItemCacheRegion
Cache region implementation using EHCache.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected net.sf.ehcache.Cacheprotected CacheLifecycleCallbackprotected net.sf.ehcache.CacheManagerprotected final CacheStatistics -
Constructor Summary
ConstructorsConstructorDescriptionEHCacheRegion(String name, int maxEntries) EHCacheRegion(String name, int maxEntries, String evictionPolicy) EHCacheRegion(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled) EHCacheRegion(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled, Long ttlSeconds) Constructor that adds possibility to configure TTL seconds for cache elements. -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves all elements from cache.booleancontainsKey(CacheKey key) Checks if key is in the cache map.protected net.sf.ehcache.config.CacheConfigurationprotected net.sf.ehcache.event.CacheEventListenerprotected CacheStatisticsvoiddestroy()Method unregisters cacheGets value from the cache.Returns all keys currently stored in this region.longGets number of cache entries above which invalidation occurs.Gets statistics for current region.String[]Gets types which can be stored in the region.longReturns number of elements currently in the cachegetName()Gets region name.getWithLoader(CacheKey key, CacheValueLoader loader) Gets value from cache.voidinit()invalidate(CacheKey key, boolean fireEventsEvenIfNotRemoved) Invalidates (removes) value from cache map.booleanvoidThis callback shall be called when eviction occurs.Removes value stored on the key specified.voidsetHandledTypes(String[] handledTypes) voidsetStatsEnabled(boolean enabled) toString()unwrap()
-
Field Details
-
lifecycleCallback
-
manager
protected net.sf.ehcache.CacheManager manager -
cacheMap
protected net.sf.ehcache.Cache cacheMap -
stats
-
-
Constructor Details
-
EHCacheRegion
-
EHCacheRegion
-
EHCacheRegion
-
EHCacheRegion
public EHCacheRegion(String name, int maxEntries, String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled, Long ttlSeconds) Constructor that adds possibility to configure TTL seconds for cache elements.- Parameters:
ttlSeconds- time to live seconds for cache elements (see EHCache docs for information about how this affects cache operations)
-
-
Method Details
-
toString
-
createCacheStatistics
-
createCacheConfiguration
protected net.sf.ehcache.config.CacheConfiguration createCacheConfiguration() -
init
@PostConstruct public void init() -
destroy
@PreDestroy public void destroy()Method unregisters cache -
createCacheEventListener
protected net.sf.ehcache.event.CacheEventListener createCacheEventListener() -
get
Description copied from interface:CacheRegionGets value from the cache. If value is absent returns null. Must be thread safe.- Specified by:
getin interfaceCacheRegion
-
getMaxReachedSize
public long getMaxReachedSize()Description copied from interface:CacheRegionReturns number of elements currently in the cache- Specified by:
getMaxReachedSizein interfaceCacheRegion
-
getWithLoader
Description copied from interface:CacheRegionGets value from cache. Invokes loader if necessary. Must be thread safe.- Specified by:
getWithLoaderin interfaceCacheRegion- Throws:
CacheValueLoadException
-
getName
Description copied from interface:CacheRegionGets region name. Needed to resolve proper cache region.- Specified by:
getNamein interfaceCacheRegion
-
getHandledTypes
Description copied from interface:CacheRegionGets types which can be stored in the region. Needed to resolve proper cache region.
Special type names are defined inRegionType.- Specified by:
getHandledTypesin interfaceCacheRegion
-
getCacheRegionStatistics
Description copied from interface:CacheRegionGets statistics for current region.- Specified by:
getCacheRegionStatisticsin interfaceCacheRegion
-
getCacheMaxEntries
public long getCacheMaxEntries()Description copied from interface:CacheRegionGets number of cache entries above which invalidation occurs.- Specified by:
getCacheMaxEntriesin interfaceCacheRegion
-
registerLifecycleCallback
Description copied from interface:CacheRegionThis callback shall be called when eviction occurs.- Specified by:
registerLifecycleCallbackin interfaceCacheRegion
-
clearCache
public void clearCache()Description copied from interface:CacheRegionRemoves all elements from cache.- Specified by:
clearCachein interfaceCacheRegion
-
invalidate
Description copied from interface:CacheRegionInvalidates (removes) value from cache map. Must be thread safe.- Specified by:
invalidatein interfaceCacheRegion- Returns:
- an object invalidated from cache.
-
getAllKeys
Description copied from interface:CacheRegionReturns all keys currently stored in this region.- Specified by:
getAllKeysin interfaceCacheRegion
-
remove
Description copied from interface:CacheRegionRemoves value stored on the key specified. This method does not update statistics. Returns value removed or null.- Specified by:
removein interfaceCacheRegion
-
setHandledTypes
- Parameters:
handledTypes- the handledTypes to set
-
containsKey
Description copied from interface:CacheRegionChecks if key is in the cache map.- Specified by:
containsKeyin interfaceCacheRegion
-
setStatsEnabled
public void setStatsEnabled(boolean enabled) - Specified by:
setStatsEnabledin interfaceCacheRegion
-
isStatsEnabled
public boolean isStatsEnabled()- Specified by:
isStatsEnabledin interfaceCacheRegion
-
unwrap
-