org.codehaus.groovy.runtime.memoize

## Class LRUCache<K,V>

- java.lang.Object
- - org.codehaus.groovy.runtime.memoize.LRUCache<K,V>

- All Implemented Interfaces:
    MemoizeCache<K,V>

      @ThreadSafe
      public final class LRUCache<K,V>
      extends Object
      implements MemoizeCache<K,V>

  A cache backed by a ConcurrentLinkedHashMap

- - ### Nested Class Summary

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

      `MemoizeCache.ValueProvider<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LRUCache(int maxCacheSize)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanUpNullReferences()` Remove all entries holding SoftReferences to gc-evicted objects.
    `V` | `get(K key)` Gets a value from the cache
    `V` | `getAndPut(K key, MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)` The implementation of `getAndPut` is not atomic
    `V` | `put(K key, V value)` Associates the specified value with the specified key in the cache.

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

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

- - ### Constructor Detail

    - #### LRUCache

          public LRUCache(int maxCacheSize)

  - ### Method Detail

    - #### put

          public V put(K key,
                       V value)

      Description copied from interface: `MemoizeCache`
      Associates the specified value with the specified key in the cache.
      Specified by:
        `put` in interface `MemoizeCache<K,V>`
      Parameters:
        `key` - key with which the specified value is to be associated
        `value` - value to be associated with the specified key
      Returns:
        null, or the old value if the key associated with the specified key.

    - #### get

          public V get(K key)

      Description copied from interface: `MemoizeCache`
      Gets a value from the cache
      Specified by:
        `get` in interface `MemoizeCache<K,V>`
      Parameters:
        `key` - the key whose associated value is to be returned
      Returns:
        the value, or null, if it does not exist.

    - #### getAndPut

          public V getAndPut(K key,
                             MemoizeCache.ValueProvider<? super K,? extends V> valueProvider)

      The implementation of `getAndPut` is not atomic
      Specified by:
        `getAndPut` in interface `MemoizeCache<K,V>`
      Returns:
        the cached value

    - #### cleanUpNullReferences

          public void cleanUpNullReferences()

      Remove all entries holding SoftReferences to gc-evicted objects.
      Specified by:
        `cleanUpNullReferences` in interface `MemoizeCache<K,V>`