Class DefaultCacheMap

  • All Implemented Interfaces:
    CacheMap

    public class DefaultCacheMap
    extends java.lang.Object
    implements CacheMap
    Default cache map implementation on the base of LinkedHashMap.
    To be used together with DefaultCacheRegion. Implementation is not thread safe.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultCacheMap​(int maxEntries)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Removes all elements from map.
      boolean contains​(CacheKey key)
      Checks if map contains value for key specified.
      protected void entryRemoved​(java.util.Map.Entry<CacheKey,​java.lang.Object> eldest)  
      java.lang.Object get​(CacheKey key)
      Gets value associated with the key.
      java.util.Collection<CacheKey> getAllKeys()
      Returns all keys currently stored in this map.
      long getCacheMaxEntries()
      Returns max cache size above which eviction occurs.
      java.lang.Object put​(CacheKey key, java.lang.Object value)
      Puts new value into the map.
      void registerEvictionCallback​(EvictionCallback callback)
      Notifies cache region when eviction occurs.
      java.lang.Object remove​(CacheKey key)
      Removes value from the map.
      long size()
      Returns number of elements currently stored in the cache
      • Methods inherited from class java.lang.Object

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

      • map

        protected final java.util.Map<CacheKey,​java.lang.Object> map
      • maxEntries

        protected final int maxEntries
    • Constructor Detail

      • DefaultCacheMap

        public DefaultCacheMap​(int maxEntries)
    • Method Detail

      • get

        public java.lang.Object get​(CacheKey key)
        Description copied from interface: CacheMap
        Gets value associated with the key. Returns null when key does not exist.
        Specified by:
        get in interface CacheMap
      • put

        public java.lang.Object put​(CacheKey key,
                                    java.lang.Object value)
        Description copied from interface: CacheMap
        Puts new value into the map. Replaces old one.
        Specified by:
        put in interface CacheMap
      • remove

        public java.lang.Object remove​(CacheKey key)
        Description copied from interface: CacheMap
        Removes value from the map.
        Specified by:
        remove in interface CacheMap
      • contains

        public boolean contains​(CacheKey key)
        Description copied from interface: CacheMap
        Checks if map contains value for key specified.
        Specified by:
        contains in interface CacheMap
      • getCacheMaxEntries

        public long getCacheMaxEntries()
        Description copied from interface: CacheMap
        Returns max cache size above which eviction occurs.
        Specified by:
        getCacheMaxEntries in interface CacheMap
      • clear

        public void clear()
        Description copied from interface: CacheMap
        Removes all elements from map.
        Specified by:
        clear in interface CacheMap
      • size

        public long size()
        Description copied from interface: CacheMap
        Returns number of elements currently stored in the cache
        Specified by:
        size in interface CacheMap
      • getAllKeys

        public java.util.Collection<CacheKey> getAllKeys()
        Description copied from interface: CacheMap
        Returns all keys currently stored in this map.
        Specified by:
        getAllKeys in interface CacheMap
      • entryRemoved

        protected void entryRemoved​(java.util.Map.Entry<CacheKey,​java.lang.Object> eldest)