Package org.codehaus.groovy.runtime.memoize

# Class ConcurrentSoftCache<K,V>

java.lang.Object
org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache<K,SoftReference<V>>
org.codehaus.groovy.runtime.memoize.ConcurrentSoftCache<K,V>

Type Parameters:
  `K` - key type
  `V` - real value type

All Implemented Interfaces:
  `Serializable`, `Map<K,SoftReference<V>>`, `EvictableCache<K,SoftReference<V>>`, `MemoizeCache<K,SoftReference<V>>`, `ValueConvertable<SoftReference<V>,Object>`

public class ConcurrentSoftCache<K,V> extends ConcurrentCommonCache<K,SoftReference<V>>
Represents concurrent cache holding SoftReference instance as value

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.EvictableCache

  `EvictableCache.Action<K,V,R>, EvictableCache.EvictionStrategy`

  ## Nested classes/interfaces inherited from interface java.util.Map

  `Map.Entry<K extends Object,V extends Object>`

  ## Nested classes/interfaces inherited from interface org.codehaus.groovy.runtime.memoize.MemoizeCache

  `MemoizeCache.ValueProvider<K,V>`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConcurrentSoftCache()`
  Constructs a cache with unlimited size
  `ConcurrentSoftCache(int maxSize)`
  Constructs a LRU cache with the default initial capacity(16)
  `ConcurrentSoftCache(int initialCapacity, int maxSize)`
  Constructs a LRU cache with the specified initial capacity and max size.
  `ConcurrentSoftCache(int initialCapacity, int maxSize, EvictableCache.EvictionStrategy evictionStrategy)`
  Constructs a cache with limited size
  `ConcurrentSoftCache(Map<K,SoftReference<V>> map)`
  Constructs a cache backed by the specified `Map` instance

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `convertValue(SoftReference<V> value)`
  convert the original value to the target value

  ### Methods inherited from class org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache

  `cleanUpNullReferences, clearAll, containsKey, containsValue, entrySet, get, getAndPut, getAndPut, isEmpty, keys, keySet, put, putAll, remove, size, values`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.runtime.memoize.EvictableCache

  `clear`

  ### Methods inherited from interface java.util.Map

  `compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll`

- ## Constructor Details

  - ### ConcurrentSoftCache

    public ConcurrentSoftCache()
    Constructs a cache with unlimited size

  - ### ConcurrentSoftCache

    public ConcurrentSoftCache(int initialCapacity, int maxSize, EvictableCache.EvictionStrategy evictionStrategy)
    Constructs a cache with limited size
    Parameters:
      `initialCapacity` - initial capacity of the cache
      `maxSize` - max size of the cache
      `evictionStrategy` - LRU or FIFO, see `EvictableCache.EvictionStrategy`

  - ### ConcurrentSoftCache

    public ConcurrentSoftCache(int initialCapacity, int maxSize)
    Constructs a LRU cache with the specified initial capacity and max size. The LRU cache is slower than `LRUCache`
    Parameters:
      `initialCapacity` - initial capacity of the LRU cache
      `maxSize` - max size of the LRU cache

  - ### ConcurrentSoftCache

    public ConcurrentSoftCache(int maxSize)
    Constructs a LRU cache with the default initial capacity(16)
    Parameters:
      `maxSize` - max size of the LRU cache
    See Also:
      - `ConcurrentSoftCache(int, int)`

  - ### ConcurrentSoftCache

    public ConcurrentSoftCache(Map<K,SoftReference<V>> map)
    Constructs a cache backed by the specified `Map` instance
    Parameters:
      `map` - the `Map` instance

- ## Method Details

  - ### convertValue

    public Object convertValue(SoftReference<V> value)
    convert the original value to the target value
    Specified by:
      `convertValue` in interface `ValueConvertable<K,V>`
    Overrides:
      `convertValue` in class `ConcurrentCommonCache<K,SoftReference<V>>`
    Parameters:
      `value` - the original value
    Returns:
      the converted value