Class AbstractMapBasedCacheRegion
- java.lang.Object
-
- de.hybris.platform.regioncache.region.impl.AbstractMapBasedCacheRegion
-
- All Implemented Interfaces:
CacheRegion
- Direct Known Subclasses:
LRUCacheRegion
,UnlimitedCacheRegion
public abstract class AbstractMapBasedCacheRegion extends java.lang.Object implements CacheRegion
Abstract class for all map based cache region implementations.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<CacheKey,java.lang.Object>
cacheMap
protected java.lang.String[]
handledTypes
protected CacheLifecycleCallback
lifecycleCallback
protected java.lang.String
name
protected CacheStatistics
stats
protected boolean
statsEnabled
-
Constructor Summary
Constructors Constructor Description AbstractMapBasedCacheRegion(java.lang.String name, boolean statsEnabled)
AbstractMapBasedCacheRegion(java.lang.String name, CacheStatistics stats, boolean statsEnabled)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clearCache()
Removes all elements from cache.boolean
containsKey(CacheKey key)
Checks if key is in the cache map.boolean
equals(java.lang.Object obj)
java.lang.Object
get(CacheKey key)
Gets value from the cache.java.util.Collection<CacheKey>
getAllKeys()
Returns all keys currently stored in this region.CacheStatistics
getCacheRegionStatistics()
Gets statistics for current region.java.lang.String[]
getHandledTypes()
Gets types which can be stored in the region.long
getMaxReachedSize()
Returns number of elements currently in the cachejava.lang.String
getName()
Gets region name.java.lang.Object
getWithLoader(CacheKey key, CacheValueLoader loader)
Gets value from cache.int
hashCode()
java.lang.Object
invalidate(CacheKey key, boolean fireEventsEvenIfNotRemoved)
Invalidates (removes) value from cache map.boolean
isStatsEnabled()
protected abstract java.lang.Object
putIfAbsent(CacheKey key, java.lang.Object value)
void
registerLifecycleCallback(CacheLifecycleCallback callback)
This callback shall be called when eviction occurs.java.lang.Object
remove(CacheKey key, boolean fireEvents)
Removes value stored on the key specified.void
setHandledTypes(java.lang.String[] handledTypes)
void
setStatsEnabled(boolean enabled)
java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.regioncache.region.CacheRegion
getCacheMaxEntries
-
-
-
-
Field Detail
-
cacheMap
protected java.util.Map<CacheKey,java.lang.Object> cacheMap
-
handledTypes
protected java.lang.String[] handledTypes
-
lifecycleCallback
protected CacheLifecycleCallback lifecycleCallback
-
name
protected final java.lang.String name
-
stats
protected final CacheStatistics stats
-
statsEnabled
protected volatile boolean statsEnabled
-
-
Constructor Detail
-
AbstractMapBasedCacheRegion
public AbstractMapBasedCacheRegion(java.lang.String name, boolean statsEnabled)
-
AbstractMapBasedCacheRegion
public AbstractMapBasedCacheRegion(java.lang.String name, CacheStatistics stats, boolean statsEnabled)
-
-
Method Detail
-
setHandledTypes
public void setHandledTypes(java.lang.String[] handledTypes)
-
getWithLoader
public java.lang.Object getWithLoader(CacheKey key, CacheValueLoader loader) throws CacheValueLoadException
Description copied from interface:CacheRegion
Gets value from cache. Invokes loader if necessary. Must be thread safe.- Specified by:
getWithLoader
in interfaceCacheRegion
- Throws:
CacheValueLoadException
-
putIfAbsent
protected abstract java.lang.Object putIfAbsent(CacheKey key, java.lang.Object value)
-
get
public java.lang.Object get(CacheKey key)
Description copied from interface:CacheRegion
Gets value from the cache. If value is absent returns null. Must be thread safe.- Specified by:
get
in interfaceCacheRegion
-
invalidate
public java.lang.Object invalidate(CacheKey key, boolean fireEventsEvenIfNotRemoved)
Description copied from interface:CacheRegion
Invalidates (removes) value from cache map. Must be thread safe.- Specified by:
invalidate
in interfaceCacheRegion
- Returns:
- an object invalidated from cache.
-
getName
public java.lang.String getName()
Description copied from interface:CacheRegion
Gets region name. Needed to resolve proper cache region.- Specified by:
getName
in interfaceCacheRegion
-
getHandledTypes
public java.lang.String[] getHandledTypes()
Description copied from interface:CacheRegion
Gets types which can be stored in the region. Needed to resolve proper cache region.
Special type names are defined inRegionType
.- Specified by:
getHandledTypes
in interfaceCacheRegion
-
getCacheRegionStatistics
public CacheStatistics getCacheRegionStatistics()
Description copied from interface:CacheRegion
Gets statistics for current region.- Specified by:
getCacheRegionStatistics
in interfaceCacheRegion
-
clearCache
public void clearCache()
Description copied from interface:CacheRegion
Removes all elements from cache.- Specified by:
clearCache
in interfaceCacheRegion
-
registerLifecycleCallback
public void registerLifecycleCallback(CacheLifecycleCallback callback)
Description copied from interface:CacheRegion
This callback shall be called when eviction occurs.- Specified by:
registerLifecycleCallback
in interfaceCacheRegion
-
getMaxReachedSize
public long getMaxReachedSize()
Description copied from interface:CacheRegion
Returns number of elements currently in the cache- Specified by:
getMaxReachedSize
in interfaceCacheRegion
-
getAllKeys
public java.util.Collection<CacheKey> getAllKeys()
Description copied from interface:CacheRegion
Returns all keys currently stored in this region.- Specified by:
getAllKeys
in interfaceCacheRegion
-
remove
public java.lang.Object remove(CacheKey key, boolean fireEvents)
Description copied from interface:CacheRegion
Removes value stored on the key specified. This method does not update statistics. Returns value removed or null.- Specified by:
remove
in interfaceCacheRegion
-
containsKey
public boolean containsKey(CacheKey key)
Description copied from interface:CacheRegion
Checks if key is in the cache map.- Specified by:
containsKey
in interfaceCacheRegion
-
setStatsEnabled
public void setStatsEnabled(boolean enabled)
- Specified by:
setStatsEnabled
in interfaceCacheRegion
-
isStatsEnabled
public boolean isStatsEnabled()
- Specified by:
isStatsEnabled
in interfaceCacheRegion
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-