Class LRUMap<K,V>
java.lang.Object
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.util.LRUMap<K,V>
- All Implemented Interfaces:
LookupCache<K,
,V> Serializable
Helper for simple bounded maps used for reusing lookup values.
Note that serialization behavior is such that contents are NOT serialized, on assumption that all use cases are for caching where persistence does not make sense. The only thing serialized is the cache size of Map.
NOTE: since Jackson 2.14, the implementation evicts the least recently used entry when max size is reached.
Since Jackson 2.12, there has been pluggable LookupCache
interface which
allows users, frameworks, provide their own cache implementations.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected final PrivateMaxEntriesMap<K,
V> protected final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Method for removing all contents this cache has.void
contents
(BiConsumer<K, V> consumer) NOTE: key is of type Object only to retain binary backwards-compatibilityputIfAbsent
(K key, V value) protected Object
int
size()
-
Field Details
-
_initialEntries
protected final int _initialEntries -
_maxEntries
protected final int _maxEntries -
_map
-
-
Constructor Details
-
LRUMap
public LRUMap(int initialEntries, int maxEntries)
-
-
Method Details
-
put
- Specified by:
put
in interfaceLookupCache<K,
V>
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceLookupCache<K,
V> - Since:
- 2.5
-
get
Description copied from interface:LookupCache
NOTE: key is of type Object only to retain binary backwards-compatibility- Specified by:
get
in interfaceLookupCache<K,
V> - Returns:
- value associated with key (can return null)
-
clear
public void clear()Description copied from interface:LookupCache
Method for removing all contents this cache has.- Specified by:
clear
in interfaceLookupCache<K,
V>
-
size
public int size()- Specified by:
size
in interfaceLookupCache<K,
V> - Returns:
- Number of entries currently in cache: may be approximate, only to be used for diagnostics, metrics reporting
-
contents
-
readResolve
-