com.opensymphony.xwork2.ognl

## Class OgnlLRUCache<Key,Value>

- java.lang.Object
- - com.opensymphony.xwork2.ognl.OgnlLRUCache<Key,Value>

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

      public class OgnlLRUCache<Key,Value>
      extends Object
      implements OgnlCache<Key,Value>

  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()`
    `Value` | `get(Key key)`
    `int` | `getEvictionLimit()`
    `void` | `put(Key key, Value value)`
    `void` | `putIfAbsent(Key key, Value 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 Value get(Key key)

      Specified by:
        `get` in interface `OgnlCache<Key,Value>`

    - #### put

          public void put(Key key,
                          Value value)

      Specified by:
        `put` in interface `OgnlCache<Key,Value>`

    - #### putIfAbsent

          public void putIfAbsent(Key key,
                                  Value value)

      Specified by:
        `putIfAbsent` in interface `OgnlCache<Key,Value>`

    - #### size

          public int size()

      Specified by:
        `size` in interface `OgnlCache<Key,Value>`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `OgnlCache<Key,Value>`

    - #### getEvictionLimit

          public int getEvictionLimit()

      Specified by:
        `getEvictionLimit` in interface `OgnlCache<Key,Value>`

    - #### setEvictionLimit

          public void setEvictionLimit(int cacheEvictionLimit)

      Specified by:
        `setEvictionLimit` in interface `OgnlCache<Key,Value>`

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