Package org.xwiki.cache.eviction
Class LRUEvictionConfiguration
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,Object>
-
- org.xwiki.cache.eviction.EntryEvictionConfiguration
-
- org.xwiki.cache.eviction.LRUEvictionConfiguration
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,Object>
public class LRUEvictionConfiguration extends EntryEvictionConfiguration
An helper forEntryEvictionConfiguration.Algorithm.NONE
cache algorithm. Evicts the least recently used entry when thresholds are hit.- Version:
- $Id: ffcbd72a3533764cefa62654dbe8eb3fbe470af5 $
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.xwiki.cache.eviction.EntryEvictionConfiguration
EntryEvictionConfiguration.Algorithm
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static String
LIFESPAN_ID
static String
MAXENTRIES_ID
The key to access the maximum entries the cache can contain.-
Fields inherited from class org.xwiki.cache.eviction.EntryEvictionConfiguration
CONFIGURATIONID, TIMETOLIVE_ID
-
-
Constructor Summary
Constructors Constructor Description LRUEvictionConfiguration()
Create a new EntryEvictionConfiguration based on LRU algorithm.LRUEvictionConfiguration(int maxEntries)
Create a new EntryEvictionConfiguration with given capacity, eviction will be based on LRU algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getLifespan()
int
getMaxEntries()
int
getMaxIdle()
void
setLifespan(int lifespan)
void
setMaxEntries(int maxEntries)
void
setMaxIdle(int maxIdle)
-
Methods inherited from class org.xwiki.cache.eviction.EntryEvictionConfiguration
getAlgorithm, getTimeToLive, setAlgorithm, setTimeToLive
-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Field Detail
-
MAXENTRIES_ID
public static final String MAXENTRIES_ID
The key to access the maximum entries the cache can contain.- See Also:
- Constant Field Values
-
LIFESPAN_ID
public static final String LIFESPAN_ID
- See Also:
getLifespan()
, Constant Field Values
-
-
Constructor Detail
-
LRUEvictionConfiguration
public LRUEvictionConfiguration()
Create a new EntryEvictionConfiguration based on LRU algorithm.
-
LRUEvictionConfiguration
public LRUEvictionConfiguration(int maxEntries)
Create a new EntryEvictionConfiguration with given capacity, eviction will be based on LRU algorithm.- Parameters:
maxEntries
- the maximum entries the cache can contain.- Since:
- 4.3M1
-
-
Method Detail
-
setMaxEntries
public void setMaxEntries(int maxEntries)
- Parameters:
maxEntries
- seegetMaxEntries()
-
getMaxEntries
public int getMaxEntries()
- Returns:
- the maximum entries the cache can contain. When the cache reaches that any element, the defined eviction algorithm kicks in to remove existing cache entries.
-
setMaxIdle
public void setMaxIdle(int maxIdle)
- Parameters:
maxIdle
- seegetMaxIdle()
- Since:
- 7.4M2
-
getMaxIdle
public int getMaxIdle()
- Returns:
- the time a cache entry will continue to stay in the cache after being last accessed, in seconds. When the time is reached, the entry is expired and removed from the cache. In addition, when the cache reaches its maximum number of entries, the defined eviction algorithm is used (e.g. LRU) and thus an entry can stay less time in the cache than its maximum defined time.
- Since:
- 7.4M2
-
setLifespan
public void setLifespan(int lifespan)
- Parameters:
lifespan
- seegetLifespan()
- Since:
- 7.4M2
-
getLifespan
public int getLifespan()
- Returns:
- the maximum lifespan of a cache entry, after which the entry is expired and removed from the cache, in seconds. In addition, when the cache reaches its maximum number of entries, the defined eviction algorithm is used (e.g. LRU) and thus an entry can stay less time in the cache than its maximum defined time.
- Since:
- 7.4M2
-
-