Cache interface to minimize the
effort required to implement a LocalCache.
| Modifier and Type | Method and Description |
|---|---|
| public default ConcurrentMap | asMap()
Implements com. |
| public default void | |
| public LocalCache | |
| public default void | cleanUp()
Implements com. |
| public default long | estimatedSize()
Implements com. |
| public default @Nullable V | get(K
the key with which the specified value is to be associated key, Function<? super K, ? extends V> the function to compute a value mappingFunction)Implements com. key in this cache, obtaining that value from the
mappingFunction if necessary.
|
| public default Map | getAll(Iterable<? extends K>
the keys whose associated values are to be returned keys, Function<? super Set<? extends K>, ? extends Map<? extends K, ? extends V>> the function to compute the values mappingFunction)Implements com. keys, creating or retrieving those
values if necessary.
|
| public default Map | getAllPresent(Iterable<? extends K>
the keys whose associated values are to be returned keys)Implements com. keys in this cache.
|
| public default @Nullable V | getIfPresent(K
the key whose associated value is to be returned key)Implements com. key in this cache, or null if there is no
cached value for the key.
|
| public default void | invalidate(K
the key whose mapping is to be removed from the cache key)Implements com. key.
|
| public default void | invalidateAll(Iterable<? extends K>
the keys whose associated values are to be removed keys)Implements com. keys.
|
| public default void | invalidateAll()
Implements com. |
| public default void | put(K
the key with which the specified value is to be associated key, V value to be associated with the specified key value)Implements com. value with the key in this cache.
|
| public default void | putAll(Map<? extends K, ? extends V>
the mappings to be stored in this cache map)Implements com. |
| public default CacheStats | stats()
Implements com. |
| asMap | back to summary |
|---|---|
| public default ConcurrentMap Implements com. Doc from com. Returns a view of the entries stored in this cache as a thread-safe map. Modifications made to the map directly affect the cache.
A computation operation, such as Iterators from the returned map are at least weakly consistent: they are safe for concurrent use, but if the cache is modified (including by eviction) after the iterator is created, it is undefined which of the changes (if any) will be reflected in that iterator.
| |
| bulkLoad | back to summary |
|---|---|
| public default void bulkLoad(Set<K> keysToLoad, Map<K, V> result, Function<? super Set<? extends K>, ? extends Map<? extends K, ? extends V>> mappingFunction) Performs a non-blocking bulk load of the missing keys. Any missing entry that materializes during the load are replaced when the loaded entries are inserted into the cache. | |
| cache | back to summary |
|---|---|
| public LocalCache Returns the backing | |
| cleanUp | back to summary |
|---|---|
| public default void cleanUp() Implements com. Doc from com. Performs any pending maintenance operations needed by the cache. Exactly which activities are performed -- if any -- is implementation-dependent.
| |
| estimatedSize | back to summary |
|---|---|
| public default long estimatedSize() Implements com. Doc from com. Returns the approximate number of entries in this cache. The value returned is an estimate; the
actual count may differ if there are concurrent insertions or removals, or if some entries are
pending removal due to expiration or weak/soft reference collection. In the case of stale
entries this inaccuracy can be mitigated by performing a
| |
| get | back to summary |
|---|---|
| public default @Nullable V get(K key, Function<? super K, ? extends V> mappingFunction) Implements com. Doc from com. Returns the value associated with the
If the specified key is not already associated with a value, attempts to compute its value
using the given mapping function and enters it into this cache unless Warning as with
| |
| getAll | back to summary |
|---|---|
| public default Map Implements com. Doc from com. Returns a map of the values associated with the
A single request to the
Note that duplicate elements in
| |
| getAllPresent | back to summary |
|---|---|
| public default Map Implements com. Doc from com. Returns a map of the values associated with the
Note that duplicate elements in | |
| getIfPresent | back to summary |
|---|---|
| public default @Nullable V getIfPresent(K key) Implements com. Doc from com. Returns the value associated with the | |
| invalidate | back to summary |
|---|---|
| public default void invalidate(K key) Implements com. Doc from com. Discards any cached value for the
| |
| invalidateAll | back to summary |
|---|---|
| public default void invalidateAll(Iterable<? extends K> keys) Implements com. Doc from com. Discards any cached values for the | |
| invalidateAll | back to summary |
|---|---|
| public default void invalidateAll() Implements com. Doc from com. Discards all entries in the cache. The behavior of this operation is undefined for an entry that is being loaded (or reloaded) and is otherwise not present.
| |
| put | back to summary |
|---|---|
| public default void put(K key, V value) Implements com. Doc from com. Associates the
Prefer
| |
| putAll | back to summary |
|---|---|
| public default void putAll(Map<? extends K, ? extends V> map) Implements com. Doc from com. Copies all of the mappings from the specified map to the cache. The effect of this call is
equivalent to that of calling | |
| stats | back to summary |
|---|---|
| public default CacheStats stats() Implements com. Doc from com. Returns a current snapshot of this cache's cumulative statistics. All statistics are initialized to zero and are monotonically increasing over the lifetime of the cache. Due to the performance penalty of maintaining statistics, some implementations may not record the usage history immediately or at all.
| |