# Class CsrfPreventionFilter.LruCache<T>

java.lang.Object
org.apache.catalina.filters.CsrfPreventionFilter.LruCache<T>

Type Parameters:
  `T` - The type held by this cache.

All Implemented Interfaces:
  `Serializable, CsrfPreventionFilter.NonceCache<T>`

Enclosing class:
  `CsrfPreventionFilter`

protected static class CsrfPreventionFilter.LruCache<T> extends Object implements CsrfPreventionFilter.NonceCache<T>
Despite its name, this is a FIFO cache not an LRU cache. Using an older nonce should not delay its removal from the cache in favour of more recent values.

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`LruCache(int cacheSize)`
Construct a new LruCache.

## Method Summary

Modifier and Type
Method
Description
`void`
`add(T key)`
Add a nonce to the cache.
`boolean`
`contains(T key)`
Check if the cache contains the given nonce.

### Methods inherited from class Object

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

## Constructor Details

### LruCache

public LruCache(int cacheSize)
Construct a new LruCache.

Parameters:
  `cacheSize` - The maximum number of entries in the cache

## Method Details

### add

public void add(T key)
Description copied from interface: `CsrfPreventionFilter.NonceCache`
Add a nonce to the cache.

Specified by:
  `add` in interface `CsrfPreventionFilter.NonceCache<T>`
Parameters:
  `key` - The nonce to add

### contains

public boolean contains(T key)
Description copied from interface: `CsrfPreventionFilter.NonceCache`
Check if the cache contains the given nonce.

Specified by:
  `contains` in interface `CsrfPreventionFilter.NonceCache<T>`
Parameters:
  `key` - The nonce to check
Returns:
  `true` if the nonce is in the cache