Interface CacheAccess
-
- All Known Implementing Classes:
CacheAccessImpl,CacheAccessInactiveImpl,CacheAccessMockImpl,MockCacheAccess
public interface CacheAccessTheCacheAccessprovides 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
All Methods Instance Methods Abstract 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 name, 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.
-
-
-
Method Detail
-
get
java.lang.Object get(java.lang.Object key)
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
java.util.Set<java.lang.Object> getKeys()
Provide the keys of all objects, which are currently in the cache region.- Returns:
- all keys.
-
put
void put(java.lang.Object key, java.lang.Object object) throws SAPHybrisCacheExceptionPuts 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
void putIfAbsent(java.lang.Object name, java.lang.Object object) throws SAPHybrisCacheExceptionPuts 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
void remove(java.lang.Object key) throws SAPHybrisCacheExceptionRemoves 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
java.lang.Object getWithLoader(java.lang.Object key, CacheValueLoader<?> loader)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.
-
-