Interface Cache<K,​V>

  • All Known Implementing Classes:
    LineCache, LruCache, StagedLruCache

    public interface Cache<K,​V>
    The base interface for a cache implementation.
    Author:
    Philipp Meinen
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_CAPACITY
      The default capacity of an object cache.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int capacity()  
      void clear()
      Remove all elements from the cache.
      V get​(K key)
      Query a value from the cache by its key.
      void remove​(K key)
      Remove a key-value-pair from the cache.
      void set​(K key, V value)
      Sets a key-value-pair to the cache.
    • Field Detail

      • DEFAULT_CAPACITY

        static final int DEFAULT_CAPACITY
        The default capacity of an object cache.
        See Also:
        Constant Field Values
    • Method Detail

      • get

        V get​(K key)
        Query a value from the cache by its key.
        Returns:
        null if no value for the given key was found. Otherwise the value for this key.
        Throws:
        IllegalArgumentException - if the key is null.
      • remove

        void remove​(K key)
        Remove a key-value-pair from the cache.
        Throws:
        IllegalArgumentException - if the key is null.
      • capacity

        int capacity()
        Returns:
        the capacity of this cache.
      • clear

        void clear()
        Remove all elements from the cache.