Class CacheMap<K,V>

java.lang.Object
com.pnfsoftware.jeb.util.collect.CacheMap<K,V>

public class CacheMap<K,V> extends Object
A simple CacheMap, with optional support for cached entries ordering.
  • Constructor Details

    • CacheMap

      public CacheMap(int maxSize, int evictSize, boolean ordered)
      Construct a cache map. Whenever an element is added and the map exceeds the maximum size, it will be partially cleaned up by evicting the last accessed objects.
      Parameters:
      maxSize - maximum size of the cache map
      evictSize - number of objects evicted during a partial cache cleanup
      ordered - true to naturally order elements in the map
    • CacheMap

      public CacheMap(int maxSize, int evictSize)
      Construct a cache map. Whenever an element is added and the map exceeds the maximum size, it will be partially cleaned up by evicting the last accessed objects.
      Parameters:
      maxSize - maximum size of the cache map
      evictSize - number of objects evicted during a partial cache cleanup
    • CacheMap

      public CacheMap(int maxSize)
      Construct a cache map with an eviction size equals to 25% of the cache size.
      Parameters:
      maxSize - maximum size of the map
  • Method Details

    • size

      public int size()
    • clear

      public void clear()
    • put

      public V put(K key, V val)
    • get

      public V get(K key)
    • containsKey

      public boolean containsKey(K key)
    • remove

      public V remove(K key)
    • removeRange

      public void removeRange(K fromKey, K toKey)