Class DefaultSynchronizationCacheService
java.lang.Object
de.hybris.platform.cmsfacades.synchronization.cache.impl.DefaultSynchronizationCacheService
- All Implemented Interfaces:
SynchronizationCacheService
public class DefaultSynchronizationCacheService
extends Object
implements SynchronizationCacheService
Default implementation of
SynchronizationCacheService.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetCacheKey(ItemModel... items) Generates the cache based on the list of items.protected <T> ObjectgetFromCacheOrRetrieve(Supplier<T> supplier, String cacheKey) Retrieves the value from cache if it exists in the cache.<T> TgetOrSetItemCache(Supplier<T> supplier, String cacheKey) Retrieves the item from the cache.<T> List<T>getOrSetItemListCache(Supplier<List<T>> supplier, String cacheKey) Retrieves the list of items from the cache.<T> List<T>getOrSetItemListCache(Supplier<List<T>> supplier, String cachePrefix, ItemModel... itemsForKeys) Retrieves the list of items from the cache.voidInitialize the cache, it creates cache objects in current session.voidsetSessionCachedContextProvider(SessionCachedContextProvider sessionCachedContextProvider)
-
Field Details
-
SYNCHRONIZATION_ITEM_CACHE
- See Also:
-
-
Constructor Details
-
DefaultSynchronizationCacheService
public DefaultSynchronizationCacheService()
-
-
Method Details
-
initCache
public void initCache()Description copied from interface:SynchronizationCacheServiceInitialize the cache, it creates cache objects in current session.- Specified by:
initCachein interfaceSynchronizationCacheService
-
getOrSetItemCache
Description copied from interface:SynchronizationCacheServiceRetrieves the item from the cache. If cache does not contain an item the supplier is called to populate the cache and return the value.- Specified by:
getOrSetItemCachein interfaceSynchronizationCacheService- Parameters:
supplier- the supplier to execute if item does not exist in cache.cacheKey- the cache key- Returns:
- the item
-
getOrSetItemListCache
Description copied from interface:SynchronizationCacheServiceRetrieves the list of items from the cache. If cache does not contain any items the supplier is called to populate the cache and return the value.- Specified by:
getOrSetItemListCachein interfaceSynchronizationCacheService- Type Parameters:
T- the type T represents any java type.- Parameters:
supplier- the supplier to execute if items does not exist in cache.cacheKey- the cache key- Returns:
- the list of items.
-
getOrSetItemListCache
public <T> List<T> getOrSetItemListCache(Supplier<List<T>> supplier, String cachePrefix, ItemModel... itemsForKeys) Description copied from interface:SynchronizationCacheServiceRetrieves the list of items from the cache. If cache does not contain any items the supplier is called to populate the cache and return the value.- Specified by:
getOrSetItemListCachein interfaceSynchronizationCacheService- Type Parameters:
T- the type T represents any java type.- Parameters:
supplier- the supplier to execute if items does not exist in cache.cachePrefix- the cache prefix (is concatenated with the cache key generated based on itemsForKeys)itemsForKeys- the list of items that are used to generate a cache key.- Returns:
- the list of items.
-
getFromCacheOrRetrieve
Retrieves the value from cache if it exists in the cache. If not exist, the value is provided by the supplier and put in the cache.- Type Parameters:
T- the type T can represent any java type (collection included)- Parameters:
supplier- the supplier of the valuecacheKey- the cache key- Returns:
- the value.
-
getCacheKey
Generates the cache based on the list of items.- Parameters:
items- the list of items.- Returns:
- the cache key.
-
getSessionCachedContextProvider
-
setSessionCachedContextProvider
public void setSessionCachedContextProvider(SessionCachedContextProvider sessionCachedContextProvider)
-