Interface Cacheable

    • Method Detail

      • isCachingEnabled

        default boolean isCachingEnabled()
        Returns true if the cache is enabled
        The default implementation returns true.
        You can override this method to modify the behavior.
        Returns:
        true if the cache is enabled
      • getCache

        default <K,​V> Cache<K,​V> getCache​(String cacheId)
        Gets the managed cache with the given id.
        It is advised to create its own business methods which call this method in order to retrieve the caches.
        For instance, if the implementing class declares two caches, you can create the two methods:
        • Cache<String, Double> getCachePriceByProductId()
        • and Cache<Integer, Boolean> getCacheAvailabilityByProductIndex()
        which simply call this method, so as to have methods to retrieve the caches with more semantic.
        Type Parameters:
        K - The type of the keys in the cache
        V - The type of the values in the cache
        Parameters:
        cacheId - The cache id
        Returns:
        The managed Cache
      • createCaches

        default void createCaches()
        Creates the managed caches.
        This is meant to be called manually, at the beginning of the lifecycle of the implementing class, in order to create and initialize the corresponding caches.
        This is not meant to be overridden.
      • removeCaches

        default void removeCaches()
        Removes the managed caches.
        This is meant to be called manually, at the end of the lifecycle of the implementing class, in order to remove the corresponding caches.
        This is not meant to be overridden.
      • hasComputableSize

        default boolean hasComputableSize()
        Determines if the cache has a computable size. This operation can be very slow.
        Returns:
        true if we can compute the size on the cache.