Class CacheAccessImpl
- java.lang.Object
-
- de.hybris.platform.regioncache.region.impl.EHCacheRegion
-
- de.hybris.platform.sap.core.bol.cache.impl.CacheAccessImpl
-
- All Implemented Interfaces:
CacheRegion,CacheAccess
- Direct Known Subclasses:
MockCacheAccess
public class CacheAccessImpl extends EHCacheRegion implements CacheAccess
Standard cache implementation class.
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.regioncache.region.impl.EHCacheRegion
cacheMap, lifecycleCallback, manager, stats
-
-
Constructor Summary
Constructors Constructor Description CacheAccessImpl(java.lang.String name, int maxEntries)Standard constructor.CacheAccessImpl(java.lang.String name, int maxEntries, java.lang.String evictionPolicy)Standard constructor.CacheAccessImpl(java.lang.String name, int maxEntries, java.lang.String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled)Standard constructor.CacheAccessImpl(java.lang.String name, int maxEntries, java.lang.String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled, java.lang.Long ttlSeconds)Standard constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache()Removes all elements from cache.java.lang.Objectget(java.lang.Object key)Gets an object from the cache for the given key.java.util.Set<java.lang.Object>getKeys()Provide the keys of all objects, which are currently in the cache region.intgetNumObjects()Returns number of objects currently stored in the cache.java.lang.ObjectgetWithLoader(java.lang.Object key, CacheValueLoader<?> loader)Gets an object from the cache using the loader to get the value.voidput(java.lang.Object key, java.lang.Object object)Puts an object into the cache region.voidputIfAbsent(java.lang.Object key, java.lang.Object object)Puts an object into the cache region, only if no object with same key already exists.voidremove(java.lang.Object key)Removes an object from the cache.voidsetHandledTypes(java.lang.String[] handledTypes)-
Methods inherited from class de.hybris.platform.regioncache.region.impl.EHCacheRegion
containsKey, createCacheConfiguration, createCacheEventListener, createCacheStatistics, destroy, get, getAllKeys, getCacheMaxEntries, getCacheRegionStatistics, getHandledTypes, getMaxReachedSize, getName, getWithLoader, init, invalidate, isStatsEnabled, registerLifecycleCallback, remove, setStatsEnabled, toString, unwrap
-
-
-
-
Constructor Detail
-
CacheAccessImpl
public CacheAccessImpl(java.lang.String name, int maxEntries)Standard constructor.- Parameters:
name- name of the cache regionmaxEntries- maximum number of entries
-
CacheAccessImpl
public CacheAccessImpl(java.lang.String name, int maxEntries, java.lang.String evictionPolicy)Standard constructor.- Parameters:
name- name of the cache regionmaxEntries- maximum number of entriesevictionPolicy- eviction policy which is used
-
CacheAccessImpl
public CacheAccessImpl(java.lang.String name, int maxEntries, java.lang.String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled)Standard constructor.- Parameters:
name- name of the cache regionmaxEntries- maximum number of entriesevictionPolicy- eviction policy which is usedexclusiveComputation- flag indicating if exclusive computation is usedstatsEnabled- flag indicating if statistics are stored or not
-
CacheAccessImpl
public CacheAccessImpl(java.lang.String name, int maxEntries, java.lang.String evictionPolicy, boolean exclusiveComputation, boolean statsEnabled, java.lang.Long ttlSeconds)Standard constructor.- Parameters:
name- name of the cache regionmaxEntries- maximum number of entriesevictionPolicy- eviction policy which is usedexclusiveComputation- flag indicating if exclusive computation is usedstatsEnabled- flag indicating if statistics are stored or notttlSeconds- time to live of the stored objects in seconds
-
-
Method Detail
-
setHandledTypes
public void setHandledTypes(java.lang.String[] handledTypes)
- Overrides:
setHandledTypesin classEHCacheRegion- Parameters:
handledTypes- the handledTypes to set
-
get
public java.lang.Object get(java.lang.Object key)
Description copied from interface:CacheAccessGets an object from the cache for the given key.- Specified by:
getin interfaceCacheAccess- Parameters:
key- name of object which should be retrieved from the cache- Returns:
- the object or
nullif the object could not be found in the cache
-
getKeys
public java.util.Set<java.lang.Object> getKeys()
Description copied from interface:CacheAccessProvide the keys of all objects, which are currently in the cache region.- Specified by:
getKeysin interfaceCacheAccess- Returns:
- all keys.
-
put
public void put(java.lang.Object key, java.lang.Object object) throws SAPHybrisCacheExceptionDescription copied from interface:CacheAccessPuts an object into the cache region.- Specified by:
putin interfaceCacheAccess- Parameters:
key- key of objectobject- object which is put into the cache- Throws:
SAPHybrisCacheException- thrown if something goes wrong while adding an object to cache
-
putIfAbsent
public void putIfAbsent(java.lang.Object key, java.lang.Object object) throws SAPHybrisCacheExceptionDescription copied from interface:CacheAccessPuts an object into the cache region, only if no object with same key already exists.- Specified by:
putIfAbsentin interfaceCacheAccess- Parameters:
key- name of objectobject- object which is put into the cache- Throws:
SAPHybrisCacheException- thrown if something goes wrong while adding an object to cache
-
remove
public void remove(java.lang.Object key) throws SAPHybrisCacheExceptionDescription copied from interface:CacheAccessRemoves an object from the cache. The cached object cannot be longer used.- Specified by:
removein interfaceCacheAccess- Parameters:
key- the name of the object which has to be removed from the cache- Throws:
SAPHybrisCacheException- if removing object fails
-
getNumObjects
public int getNumObjects()
Description copied from interface:CacheAccessReturns number of objects currently stored in the cache.- Specified by:
getNumObjectsin interfaceCacheAccess- Returns:
- number of objects currently stored in the cache.
-
getWithLoader
public java.lang.Object getWithLoader(java.lang.Object key, CacheValueLoader<?> loader)Description copied from interface:CacheAccessGets an object from the cache using the loader to get the value.- Specified by:
getWithLoaderin interfaceCacheAccess- Parameters:
key- the name of the object which has to loadedloader- the loader object which is used to load the value- Returns:
- number of objects currently stored in the cache.
-
clearCache
public void clearCache()
Description copied from interface:CacheRegionRemoves all elements from cache.- Specified by:
clearCachein interfaceCacheAccess- Specified by:
clearCachein interfaceCacheRegion- Overrides:
clearCachein classEHCacheRegion
-
-