Interface Cache<K,V>

Type Parameters:
K - the type of keys
V - the type of mapped values
All Known Implementing Classes:
ConcurrentLruCache

public interface Cache<K,V>
A Map-like data structure that stores key-value pairs and provides temporary access to it.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the contents of the cache.
    get(K key)
    Gets an entry from the cache.
    boolean
    Returns true if this cache contains no key-value mappings.
    Returns a Set view of the keys contained in this cache.
    void
    put(K key, V value)
    Associates the specified value with the specified key in the cache.
    void
    remove(K key)
    Removes an entry from the cache.
    int
     
  • Method Details

    • get

      V get(K key)
      Gets an entry from the cache.
      Parameters:
      key - the key whose associated value is to be returned
      Returns:
      the element, or null, if it does not exist.
    • put

      void put(K key, V value)
      Associates the specified value with the specified key in the cache.
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      Throws:
      NullPointerException - if key is null or if value is null
    • clear

      void clear()
      Clears the contents of the cache.
    • remove

      void remove(K key)
      Removes an entry from the cache.
      Parameters:
      key - key with which the specified value is to be associated.
    • keySet

      Set<K> keySet()
      Returns a Set view of the keys contained in this cache.
    • size

      int size()
      Returns:
      the current size of the cache
    • isEmpty

      boolean isEmpty()
      Returns true if this cache contains no key-value mappings.