Class MemoryCachePlus<K,V>

  • Type Parameters:
    K - the key type.
    V - the value type.


    public class MemoryCachePlus<K,V>
    extends Object
    • Constructor Summary

      Constructors

      Constructor and Description
      MemoryCachePlus(int size)
      Create a memory cache.
    • Constructor Detail

      • MemoryCachePlus

        public MemoryCachePlus(int size)
        Create a memory cache.
        Parameters:
        size - the number of elements to store.
    • Method Detail

      • getSize

        public int getSize()
      • setSize

        public void setSize(int size)
      • put

        public K put(K key,
                     V value)
        Put key, value into the cache.
        Parameters:
        key - the key.
        value - the value.
        Returns:
        the key removed or null
      • get

        public V get(K key)
        Get the stored element.
        Parameters:
        key - the key to retrieve a value for.
        Returns:
        the value.
      • remove

        public V remove(K key)
        Remove and get the stored element if any.
        Parameters:
        key - the key to remove the value for.
        Returns:
        the removed element or null.
      • refresh

        public void refresh(K key)
        Reorder the key within the replacement list.
        Parameters:
        key - the key to reorder.
      • clear

        public void clear()
        Clear this cache. Removes all elements.