Class ProductConfigurationEHCacheAccessImpl<K extends CacheKey,V>
- java.lang.Object
-
- de.hybris.platform.sap.productconfig.runtime.interf.cache.impl.ProductConfigurationEHCacheAccessImpl<K,V>
-
- All Implemented Interfaces:
ProductConfigurationCacheAccess<K,V>
public class ProductConfigurationEHCacheAccessImpl<K extends CacheKey,V> extends java.lang.Object implements ProductConfigurationCacheAccess<K,V>
-
-
Constructor Summary
Constructors Constructor Description ProductConfigurationEHCacheAccessImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCache()
Removes all elements from cache.V
get(K key)
Gets a value from the cache for the given key.protected EHCacheRegion
getCache()
java.util.Set<K>
getKeys()
Provide the keys of all values, which are currently in the cache region.V
getWithLoader(K key, CacheValueLoader<V> loader)
Gets a value from the cache using the loader to get the value.V
getWithSupplier(K key, java.util.function.Supplier<V> supplier)
Gets a value from the cache for the given key.void
put(K key, V value)
Puts a value into the cache region.void
putIfAbsent(K key, V value)
Puts a value into the cache region, only if no value with same key already exists.void
remove(K key)
Removes a value from the cache.void
setCache(EHCacheRegion cache)
-
-
-
Method Detail
-
get
public V get(K key)
Description copied from interface:ProductConfigurationCacheAccess
Gets a value from the cache for the given key.- Specified by:
get
in interfaceProductConfigurationCacheAccess<K extends CacheKey,V>
- Parameters:
key
- K of object which should be retrieved from the cache- Returns:
- the value or
null
if the value could not be found in the cache
-
getKeys
public java.util.Set<K> getKeys()
Description copied from interface:ProductConfigurationCacheAccess
Provide the keys of all values, which are currently in the cache region.- Specified by:
getKeys
in interfaceProductConfigurationCacheAccess<K extends CacheKey,V>
- Returns:
- all keys.
-
getWithSupplier
public V getWithSupplier(K key, java.util.function.Supplier<V> supplier)
Description copied from interface:ProductConfigurationCacheAccess
Gets a value from the cache for the given key. If the value is not present in the cache the supplier will be called and the returned value will be cached.- Specified by:
getWithSupplier
in interfaceProductConfigurationCacheAccess<K extends CacheKey,V>
- Parameters:
key
- key of valuesupplier
- supplier which returns the value- Returns:
- the value
-
getWithLoader
public V getWithLoader(K key, CacheValueLoader<V> loader)
Description copied from interface:ProductConfigurationCacheAccess
Gets a value from the cache using the loader to get the value.- Specified by:
getWithLoader
in interfaceProductConfigurationCacheAccess<K extends CacheKey,V>
- Parameters:
key
- the key of the value which has to loadedloader
- the loader object which is used to load the value- Returns:
- number of objects currently stored in the cache.
-
put
public void put(K key, V value)
Description copied from interface:ProductConfigurationCacheAccess
Puts a value into the cache region.- Specified by:
put
in interfaceProductConfigurationCacheAccess<K extends CacheKey,V>
- Parameters:
key
- key of valuevalue
- value which is put into the cache
-
putIfAbsent
public void putIfAbsent(K key, V value)
Description copied from interface:ProductConfigurationCacheAccess
Puts a value into the cache region, only if no value with same key already exists.- Specified by:
putIfAbsent
in interfaceProductConfigurationCacheAccess<K extends CacheKey,V>
- Parameters:
key
- key of valuevalue
- value which is put into the cache
-
remove
public void remove(K key)
Description copied from interface:ProductConfigurationCacheAccess
Removes a value from the cache. The cached value cannot be longer used.- Specified by:
remove
in interfaceProductConfigurationCacheAccess<K extends CacheKey,V>
- Parameters:
key
- the key of the value which has to be removed from the cache
-
clearCache
public void clearCache()
Description copied from interface:ProductConfigurationCacheAccess
Removes all elements from cache.- Specified by:
clearCache
in interfaceProductConfigurationCacheAccess<K extends CacheKey,V>
-
getCache
protected EHCacheRegion getCache()
-
setCache
public void setCache(EHCacheRegion cache)
-
-