Class SoftRefCache

  • All Implemented Interfaces:
    java.util.Map<java.lang.Object,​DNStateManager>, Level1Cache

    public class SoftRefCache
    extends java.lang.Object
    implements Level1Cache
    Level 1 Cache using Soft referenced objects in a Map.

    If map entry value object is not actively being used, i.e. no other object has a strong reference to it, it may become garbage collected at the discretion of the garbage collector (typically if the VM is low on memory). If this happens, the entry in the SoftValueMap corresponding to the value object will also be removed.

    See Also:
    SoftReference
    • Constructor Detail

      • SoftRefCache

        public SoftRefCache()
    • Method Detail

      • get

        public DNStateManager get​(java.lang.Object id)
        Specified by:
        get in interface java.util.Map<java.lang.Object,​DNStateManager>
      • containsKey

        public boolean containsKey​(java.lang.Object id)
        Specified by:
        containsKey in interface java.util.Map<java.lang.Object,​DNStateManager>
      • remove

        public DNStateManager remove​(java.lang.Object id)
        Specified by:
        remove in interface java.util.Map<java.lang.Object,​DNStateManager>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<java.lang.Object,​DNStateManager>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<java.lang.Object,​DNStateManager>
      • entrySet

        public java.util.Set entrySet()
        Specified by:
        entrySet in interface java.util.Map<java.lang.Object,​DNStateManager>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<java.lang.Object,​DNStateManager>
      • keySet

        public java.util.Set keySet()
        Specified by:
        keySet in interface java.util.Map<java.lang.Object,​DNStateManager>
      • putAll

        public void putAll​(java.util.Map t)
        Specified by:
        putAll in interface java.util.Map<java.lang.Object,​DNStateManager>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<java.lang.Object,​DNStateManager>
      • values

        public java.util.Collection values()
        Specified by:
        values in interface java.util.Map<java.lang.Object,​DNStateManager>
      • getUnique

        public DNStateManager getUnique​(CacheUniqueKey key)
        Description copied from interface: Level1Cache
        Method to retrieve StateManager for the specified unique key.
        Specified by:
        getUnique in interface Level1Cache
        Parameters:
        key - Unique key
        Returns:
        StateManager if one is cached for this unique key
      • putUnique

        public java.lang.Object putUnique​(CacheUniqueKey key,
                                          DNStateManager sm)
        Description copied from interface: Level1Cache
        Method to store a StateManager for this unique key.
        Specified by:
        putUnique in interface Level1Cache
        Parameters:
        key - The unique key
        sm - StateManager
        Returns:
        The previous StateManager for this unique key if one was present, otherwise null