Interface CacheAccess
- All Known Implementing Classes:
CacheAccessImpl,CacheAccessInactiveImpl,CacheAccessMockImpl,MockCacheAccess
public interface CacheAccess
The
CacheAccess provides the direct access to a cache region. This class should only be used for the
migration of existing SAP application modules. For other caching scenarios use the Hybris Cache Framework.-
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves all elements from cache.Gets an object from the cache for the given key.getKeys()Provide the keys of all objects, which are currently in the cache region.intReturns number of objects currently stored in the cache.getWithLoader(Object key, de.hybris.platform.regioncache.CacheValueLoader<?> loader) Gets an object from the cache using the loader to get the value.voidPuts an object into the cache region.voidputIfAbsent(Object name, Object object) Puts an object into the cache region, only if no object with same key already exists.voidRemoves an object from the cache.
-
Method Details
-
get
Gets an object from the cache for the given key.- 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
Provide the keys of all objects, which are currently in the cache region.- Returns:
- all keys.
-
put
Puts an object into the cache region.- 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
Puts an object into the cache region, only if no object with same key already exists.- Parameters:
name- name of objectobject- object which is put into the cache- Throws:
SAPHybrisCacheException- thrown if something goes wrong while adding an object to cache
-
remove
Removes an object from the cache. The cached object cannot be longer used.- Parameters:
key- the name of the object which has to be removed from the cache- Throws:
SAPHybrisCacheException- if removing object fails
-
getNumObjects
int getNumObjects()Returns number of objects currently stored in the cache.- Returns:
- number of objects currently stored in the cache.
-
getWithLoader
Gets an object from the cache using the loader to get the value.- 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
void clearCache()Removes all elements from cache.
-