Class AbstractJPPFMapCache<K,V>

java.lang.Object
org.jppf.caching.AbstractJPPFMapCache<K,V>
Type Parameters:
K - the type of keys.
V - the type of values.
All Implemented Interfaces:
JPPFMapCache<K,V>
Direct Known Subclasses:
JPPFHashMapCache, JPPFLRUMapCache

public abstract class AbstractJPPFMapCache<K,V> extends Object implements JPPFMapCache<K,V>
A map cache with a LRU eviction policy.
Author:
Laurent Cohen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Map<K,V>
    The backing map for this cache.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the cache.
    protected abstract Map<K,V>
    Create the backing map.
    get(K key)
    Get an element in the cache.
    boolean
    has(K key)
    Determine whether an entry with the specified key is in the cache.
    void
    put(K key, V value)
    Put an element in the cache.
    remove(K key)
    Remove an element from the cache.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • map

      protected Map<K,V> map
      The backing map for this cache.
  • Constructor Details

    • AbstractJPPFMapCache

      public AbstractJPPFMapCache()
  • Method Details

    • createMap

      protected abstract Map<K,V> createMap()
      Create the backing map.
      Returns:
      a map for this cache.
    • put

      public void put(K key, V value)
      Description copied from interface: JPPFMapCache
      Put an element in the cache.
      Specified by:
      put in interface JPPFMapCache<K,V>
      Parameters:
      key - the element's key for retrival.
      value - the element's value.
    • get

      public V get(K key)
      Description copied from interface: JPPFMapCache
      Get an element in the cache.
      Specified by:
      get in interface JPPFMapCache<K,V>
      Parameters:
      key - the element's key.
      Returns:
      the value of the element, or null if the element is not in the cache.
    • remove

      public V remove(K key)
      Description copied from interface: JPPFMapCache
      Remove an element from the cache.
      Specified by:
      remove in interface JPPFMapCache<K,V>
      Parameters:
      key - the element's key.
      Returns:
      the value of the removed element, or null if the element is not in the cache.
    • clear

      public void clear()
      Description copied from interface: JPPFMapCache
      Clear the cache. This removes all elements from the cache.
      Specified by:
      clear in interface JPPFMapCache<K,V>
    • has

      public boolean has(K key)
      Description copied from interface: JPPFMapCache
      Determine whether an entry with the specified key is in the cache.
      Specified by:
      has in interface JPPFMapCache<K,V>
      Parameters:
      key - the key to look up.
      Returns:
      true if the key is in the cache, false otherwise.