com.opensymphony.xwork2.ognl

## Class OgnlLRUCache<K,V>

- java.lang.Object
- - com.opensymphony.xwork2.ognl.OgnlLRUCache<K,V>

- Type Parameters:
    `K` - The type for the cache key entries
    `V` - The type for the cache value entries
  All Implemented Interfaces:
    OgnlCache<K,V>

      public class OgnlLRUCache<K,V>
      extends Object
      implements OgnlCache<K,V>

  A basic OGNL LRU cache implementation.

  The implementation utilizes a `Collections.synchronizedMap(java.util.Map)` backed by a `LinkedHashMap`. May be replaced by a more efficient implementation in the future.

  Setting too low an eviction limit will produce more overhead than value.

  Setting too high an eviction limit may also produce more overhead than value.

  An appropriate eviction limit will need to be determined on an individual application basis.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OgnlLRUCache(int evictionLimit, int initialCapacity, float loadFactor)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()`
    `V` | `get(K key)`
    `int` | `getEvictionLimit()`
    `void` | `put(K key, V value)`
    `void` | `putIfAbsent(K key, V value)`
    `void` | `setEvictionLimit(int cacheEvictionLimit)`
    `int` | `size()`

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

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

- - ### Constructor Detail

    - #### OgnlLRUCache

          public OgnlLRUCache(int evictionLimit,
                              int initialCapacity,
                              float loadFactor)

  - ### Method Detail

    - #### get

          public V get(K key)

      Specified by:
        `get` in interface `OgnlCache<K,V>`

    - #### put

          public void put(K key,
                          V value)

      Specified by:
        `put` in interface `OgnlCache<K,V>`

    - #### putIfAbsent

          public void putIfAbsent(K key,
                                  V value)

      Specified by:
        `putIfAbsent` in interface `OgnlCache<K,V>`

    - #### size

          public int size()

      Specified by:
        `size` in interface `OgnlCache<K,V>`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `OgnlCache<K,V>`

    - #### getEvictionLimit

          public int getEvictionLimit()

      Specified by:
        `getEvictionLimit` in interface `OgnlCache<K,V>`

    - #### setEvictionLimit

          public void setEvictionLimit(int cacheEvictionLimit)

      Specified by:
        `setEvictionLimit` in interface `OgnlCache<K,V>`

Copyright © 2000–2024 Apache Software Foundation. All rights reserved.