LRUCache (ActiveMQ Artemis Web 1.1.0.wildfly-010 API)
Date: 2015-12-18

org.apache.activemq.artemis.selector.impl

## Class LRUCache<K,V>

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - java.util.HashMap<K,V>
    - - java.util.LinkedHashMap<K,V>
      - - org.apache.activemq.artemis.selector.impl.LRUCache<K,V>

- Type Parameters:
    `K` -
    `V` -
  All Implemented Interfaces:
    Serializable, Cloneable, Map<K,V>

      public class LRUCache<K,V>
      extends LinkedHashMap<K,V>

  A Simple LRU Cache
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.util.AbstractMap

      `AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `maxCacheSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LRUCache()` Default constructor for an LRU Cache The default capacity is 10000
    `LRUCache(int maximumCacheSize)` Constructs a LRUCache with a maximum capacity
    `LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder)` Constructs an empty `LRUCache` instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getMaxCacheSize()`
    `protected void` | `onCacheEviction(Map.Entry<K,V> eldest)`
    `protected boolean` | `removeEldestEntry(Map.Entry<K,V> eldest)`
    `void` | `setMaxCacheSize(int maxCacheSize)`

    - ### Methods inherited from class java.util.LinkedHashMap

      `clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, values`

    - ### Methods inherited from class java.util.HashMap

      `clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size`

    - ### Methods inherited from class java.util.AbstractMap

      `equals, hashCode, toString`

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

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

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

      `compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size`

- - ### Field Detail

    - #### maxCacheSize

          protected int maxCacheSize

  - ### Constructor Detail

    - #### LRUCache

          public LRUCache()

      Default constructor for an LRU Cache The default capacity is 10000

    - #### LRUCache

          public LRUCache(int maximumCacheSize)

      Constructs a LRUCache with a maximum capacity
      Parameters:
        `maximumCacheSize` -

    - #### LRUCache

          public LRUCache(int initialCapacity,
                          int maximumCacheSize,
                          float loadFactor,
                          boolean accessOrder)

      Constructs an empty `LRUCache` instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
      Parameters:
        `initialCapacity` - the initial capacity.
        `maximumCacheSize` -
        `loadFactor` - the load factor.
        `accessOrder` - the ordering mode - `true` for access-order, `false` for insertion-order.
      Throws:
        `IllegalArgumentException` - if the initial capacity is negative or the load factor is non-positive.

  - ### Method Detail

    - #### getMaxCacheSize

          public int getMaxCacheSize()

      Returns:
        Returns the maxCacheSize.

    - #### setMaxCacheSize

          public void setMaxCacheSize(int maxCacheSize)

      Parameters:
        `maxCacheSize` - The maxCacheSize to set.

    - #### removeEldestEntry

          protected boolean removeEldestEntry(Map.Entry<K,V> eldest)

      Overrides:
        `removeEldestEntry` in class `LinkedHashMap<K,V>`

    - #### onCacheEviction

          protected void onCacheEviction(Map.Entry<K,V> eldest)

Copyright © 2015. All rights reserved.