Interface RenderingCacheService<T extends java.io.Serializable>

  • All Known Implementing Classes:
    DefaultRenderingCacheService

    public interface RenderingCacheService<T extends java.io.Serializable>
    Service to cache ItemModel data representation for rendering. The type T can be represented by any Data or Model type.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean cacheEnabled()
      Verifies whether the cache is enabled or not.
      T cacheOrElse​(ItemModel item, java.util.function.Supplier<T> converter)
      Methods takes the ItemModel, verifies that the Serializable representation is cached and returns it.
      java.util.Optional<T> get​(CacheKey key)
      Returns cached Serializable.
      java.util.Optional<CacheKey> getKey​(ItemModel item)
      Retrieves the key that must be used to cache Serializable.
      void put​(CacheKey key, T item)
      Puts the Serializable into the cache using provided key.
    • Method Detail

      • cacheEnabled

        boolean cacheEnabled()
        Verifies whether the cache is enabled or not.
        Returns:
        true if cache is enabled, false otherwise
      • get

        java.util.Optional<T> get​(CacheKey key)
        Returns cached Serializable.
        Parameters:
        key - the key used to retrieve cached Serializable
        Returns:
        optional cached Serializable.
      • put

        void put​(CacheKey key,
                 T item)
        Puts the Serializable into the cache using provided key.
        Parameters:
        key - the key used to save Serializable
        item - the Serializable that must be cached.
      • getKey

        java.util.Optional<CacheKey> getKey​(ItemModel item)
        Retrieves the key that must be used to cache Serializable. The key is retrieved by ItemModel.
        Parameters:
        item - the ItemModel for which to retrieve the key.
        Returns:
        the key
      • cacheOrElse

        T cacheOrElse​(ItemModel item,
                      java.util.function.Supplier<T> converter)
        Methods takes the ItemModel, verifies that the Serializable representation is cached and returns it. If the item is not in the cache the converter is called and Serializable representation is saved into the cache.
        Parameters:
        item - the ItemModel to cache.
        converter - the converter to use if the ItemModel is not in the cache.
        Returns:
        the Serializable representation for rendering.