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>
    Cache interface
    Author:
    pwinckles
    • 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