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 initial and maximum size of the contents.
The implementation evicts the least recently used
entry when max size is reached; this is implemented by the backing
PrivateMaxEntriesMap implementation.
Implementation is thread-safe and does NOT require external synchronization
Note
in Jackson 2.x this class was named com.fasterxml.jackson.databind.util.LRUMap
| Modifier and Type | Field and Description |
|---|---|
| protected final int | |
| protected final transient PrivateMaxEntriesMap | |
| protected final int | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements tools. Method for removing all contents this cache has. |
| public void | contents(BiConsumer<K, V> consumer)
Overrides default tools. Method to apply operation on cache contents without exposing them. |
| public LookupCache | emptyCopy()
Implements tools. Method needed for creating clones but without contents. |
| public V | |
| public V | |
| public V | |
| protected Object | |
| public int | |
| public SimpleLookupCache | snapshot()
Implements tools. Method to call to get an instance that may not be modified through any other object, including `this`. |
| _initialEntries | back to summary |
|---|---|
| protected final int _initialEntries | |
| _map | back to summary |
|---|---|
| protected final transient PrivateMaxEntriesMap<K, V> _map | |
| _maxEntries | back to summary |
|---|---|
| protected final int _maxEntries | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| SimpleLookupCache | back to summary |
|---|---|
| public SimpleLookupCache(int initialEntries, int maxEntries) | |
| clear | back to summary |
|---|---|
| public void clear() Implements tools. Doc from tools. Method for removing all contents this cache has.
| |
| contents | back to summary |
|---|---|
| public void contents(BiConsumer<K, V> consumer) Overrides default tools. Doc from tools. Method to apply operation on cache contents without exposing them.
Default implementation throws
| |
| emptyCopy | back to summary |
|---|---|
| public LookupCache Implements tools. Doc from tools. Method needed for creating clones but without contents.
| |
| get | back to summary |
|---|---|
| public V get(K key) Implements tools.
| |
| put | back to summary |
|---|---|
| public V put(K key, V value) Implements tools.
| |
| putIfAbsent | back to summary |
|---|---|
| public V putIfAbsent(K key, V value) Implements tools.
| |
| readResolve | back to summary |
|---|---|
| protected Object readResolve() | |
| size | back to summary |
|---|---|
| public int size() Implements tools.
| |
| snapshot | back to summary |
|---|---|
| public SimpleLookupCache Implements tools. Doc from tools. Method to call to get an instance that may not be modified through any other object, including `this`. That instance may be `this` if (and only if) this instance is effectively immutable (unmodifiable) through its API: if this is not the case, a new copy with same configuration must be created and returned.
| |