Interface Cache<K,​V>

  • Type Parameters:
    K - type of cache key
    V - type of cache value
    All Known Implementing Classes:
    CaffeineCache, NoOpCache

    public interface Cache<K,​V>
    Extension point that allows the OCFL repository to use any number of different cache implementations so long as they conform to this interface.
    See Also:
    CaffeineCache
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean contains​(K key)
      Returns true if the cache contains the specified key
      V get​(K key, Function<K,​V> loader)
      Retrieves a value from the cache.
      void invalidate​(K key)
      Invalidates the key in the cache.
      void invalidateAll()
      Invalidates the entire cache
      void put​(K key, V value)
      Inserts a value into the cache.
    • Method Detail

      • get

        V get​(K key,
              Function<K,​V> loader)
        Retrieves a value from the cache. If it doesn't exist, the loader is called to load the object, which is then cached and returned.
        Parameters:
        key - to lookup in the cache
        loader - function to call to load the object if it's not found
        Returns:
        the object that maps to the key
      • put

        void put​(K key,
                 V value)
        Inserts a value into the cache.
        Parameters:
        key - key
        value - value
      • invalidate

        void invalidate​(K key)
        Invalidates the key in the cache.
        Parameters:
        key - key
      • invalidateAll

        void invalidateAll()
        Invalidates the entire cache
      • contains

        boolean contains​(K key)
        Returns true if the cache contains the specified key
        Parameters:
        key - key
        Returns:
        true if the cache contains the key