com.opensymphony.xwork2.ognl

## Class OgnlCaffeineCache<K,V>

- java.lang.Object
- - com.opensymphony.xwork2.ognl.OgnlCaffeineCache<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 OgnlCaffeineCache<K,V>
      extends Object
      implements OgnlCache<K,V>

  This OGNL Cache implementation is backed by `Caffeine` which uses the Window TinyLfu algorithm.

  An appropriate eviction limit should be chosen for your specific application based on factors and requirements such as:

  - Quantity and complexity of actions
  - Volume of requests
  - Rate limits and attack potential/patterns
  - Memory constraints

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OgnlCaffeineCache(int evictionLimit, int initialCapacity)`

  - ### 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)`
    `V` | `remove(K key)` Removes the mapping for the given key, if present.
    `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

    - #### OgnlCaffeineCache

          public OgnlCaffeineCache(int evictionLimit,
                                   int initialCapacity)

  - ### 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>`

    - #### remove

          public V remove(K key)

      Description copied from interface: `OgnlCache`
      Removes the mapping for the given key, if present.
      Specified by:
        `remove` in interface `OgnlCache<K,V>`
      Parameters:
        `key` - the key to remove
      Returns:
        the previous value associated with the key, or `null` if none

    - #### 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–2026 Apache Software Foundation. All rights reserved.