Class DefaultSynchronizationCacheService

    • Field Detail

      • SYNCHRONIZATION_ITEM_CACHE

        public static final java.lang.String SYNCHRONIZATION_ITEM_CACHE
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultSynchronizationCacheService

        public DefaultSynchronizationCacheService()
    • Method Detail

      • getOrSetItemCache

        public <T> T getOrSetItemCache​(java.util.function.Supplier<T> supplier,
                                       java.lang.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> java.util.List<T> getOrSetItemListCache​(java.util.function.Supplier<java.util.List<T>> supplier,
                                                           java.lang.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> java.util.List<T> getOrSetItemListCache​(java.util.function.Supplier<java.util.List<T>> supplier,
                                                           java.lang.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> java.lang.Object getFromCacheOrRetrieve​(java.util.function.Supplier<T> supplier,
                                                              java.lang.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 java.lang.String getCacheKey​(ItemModel... items)
        Generates the cache based on the list of items.
        Parameters:
        items - the list of items.
        Returns:
        the cache key.
      • setSessionCachedContextProvider

        public void setSessionCachedContextProvider​(SessionCachedContextProvider sessionCachedContextProvider)