public class LRUMap<K,V> extends java.lang.Object implements LookupCache<K,V>, java.io.Serializable
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 version 2.4.2, this is NOT an LRU-based at all; reason being that it is not possible to use JDK components that do LRU _AND_ perform well wrt synchronization on multi-core systems. So we choose efficient synchronization over potentially more efficient handling of entries.
And yes, there are efficient LRU implementations such as
concurrentlinkedhashmap;
but at this point we really try to keep external deps to minimum.
Plan from Jackson 2.12 is to focus more on pluggability as LookupCache and
let users, frameworks, provide their own cache implementations.
| Constructor and Description |
|---|
LRUMap(int initialEntries,
int maxEntries) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Method for removing all contents this cache has.
|
V |
get(java.lang.Object key)
NOTE: key is of type Object only to retain binary backwards-compatibility
|
V |
put(K key,
V value) |
V |
putIfAbsent(K key,
V value) |
int |
size() |
public V putIfAbsent(K key, V value)
putIfAbsent in interface LookupCache<K,V>public V get(java.lang.Object key)
LookupCacheget in interface LookupCache<K,V>public void clear()
LookupCacheclear in interface LookupCache<K,V>public int size()
size in interface LookupCache<K,V>Copyright © 2010 - 2023 Adobe. All Rights Reserved