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 Details

  • Constructor Details

    • DefaultSynchronizationCacheService

      public DefaultSynchronizationCacheService()
  • Method Details

    • initCache

      public void initCache()
      Description copied from interface: SynchronizationCacheService
      Initialize the cache, it creates cache objects in current session.
      Specified by:
      initCache in interface SynchronizationCacheService
    • getOrSetItemCache

      public <T> T getOrSetItemCache(Supplier<T> supplier, String cacheKey)
      Description copied from interface: SynchronizationCacheService
      Retrieves 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:
      getOrSetItemCache in interface SynchronizationCacheService
      Parameters:
      supplier - the supplier to execute if item does not exist in cache.
      cacheKey - the cache key
      Returns:
      the item
    • getOrSetItemListCache

      public <T> List<T> getOrSetItemListCache(Supplier<List<T>> supplier, String cacheKey)
      Description copied from interface: SynchronizationCacheService
      Retrieves 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:
      getOrSetItemListCache in interface SynchronizationCacheService
      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: SynchronizationCacheService
      Retrieves 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:
      getOrSetItemListCache in interface SynchronizationCacheService
      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

      protected <T> Object getFromCacheOrRetrieve(Supplier<T> supplier, String cacheKey)
      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 value
      cacheKey - the cache key
      Returns:
      the value.
    • getCacheKey

      protected String getCacheKey(ItemModel... items)
      Generates the cache based on the list of items.
      Parameters:
      items - the list of items.
      Returns:
      the cache key.
    • getSessionCachedContextProvider

      public SessionCachedContextProvider getSessionCachedContextProvider()
    • setSessionCachedContextProvider

      public void setSessionCachedContextProvider(SessionCachedContextProvider sessionCachedContextProvider)