get(Object, Function) or put(Object, Object), and are stored in the cache until
either evicted or manually invalidated.
Implementations of this interface are expected to be thread-safe and can be safely accessed by multiple concurrent threads.
| Modifier and Type | Method and Description |
|---|---|
| public ConcurrentMap | |
| public void | |
| public @NonNegative long | Returns: the estimated number of mappingsReturns the approximate number of entries in this cache. |
| public @PolyNull V | Returns: the current (existing or computed) value associated with the specified key, or null if the computed value is nullthe key with which the specified value is to be associated key, Function<? super K, ? extends @PolyNull V> the function to compute a value mappingFunction)Returns the value associated with the |
| public Map | Returns: an unmodifiable mapping of keys to values for the specified keys in this cachethe 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)Returns a map of the values associated with the |
| public Map | Returns: an unmodifiable mapping of keys to values for the specified keys found in this cachethe keys whose associated values are to be returned keys)Returns a map of the values associated with the |
| public @Nullable V | Returns: the value to which the specified key is mapped, ornull if this cache does not
contain a mapping for the keythe key whose associated value is to be returned key)Returns the value associated with the |
| public void | invalidate(K
the key whose mapping is to be removed from the cache key)Discards any cached value for the |
| public void | invalidateAll(Iterable<? extends K>
the keys whose associated values are to be removed keys)Discards any cached values for the |
| public void | |
| public Policy | Returns: access to inspect and perform advanced operations based on the cache's characteristicsReturns access to inspect and perform low-level operations on this cache based on its runtime characteristics. |
| public 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)Associates the |
| public void | |
| public CacheStats | Returns: the current snapshot of the statistics of this cacheReturns a current snapshot of this cache's cumulative statistics. |
| asMap | back to summary |
|---|---|
| public ConcurrentMap 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.
| |
| cleanUp | back to summary |
|---|---|
| public void cleanUp() Performs any pending maintenance operations needed by the cache. Exactly which activities are performed -- if any -- is implementation-dependent. | |
| estimatedSize | back to summary |
|---|---|
| public @NonNegative long estimatedSize() 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 @PolyNull V get(K key, Function<? super K, ? extends @PolyNull V> mappingFunction) 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 Map Returns a map of the values associated with the
A single request to the
Note that duplicate elements in
| |
| getAllPresent | back to summary |
|---|---|
| public Map Returns a map of the values associated with the
Note that duplicate elements in
| |
| getIfPresent | back to summary |
|---|---|
| public @Nullable V getIfPresent(K key) Returns the value associated with the
| |
| invalidate | back to summary |
|---|---|
| public void invalidate(K key) Discards any cached value for the
| |
| invalidateAll | back to summary |
|---|---|
| public void invalidateAll(Iterable<? extends K> keys) Discards any cached values for the
| |
| invalidateAll | back to summary |
|---|---|
| public void invalidateAll() 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. | |
| policy | back to summary |
|---|---|
| public Policy Returns access to inspect and perform low-level operations on this cache based on its runtime characteristics. These operations are optional and dependent on how the cache was constructed and what abilities the implementation exposes. Warning policy operations must not be performed from within an atomic scope of another cache operation.
| |
| put | back to summary |
|---|---|
| public void put(K key, V value) Associates the
Prefer
| |
| putAll | back to summary |
|---|---|
| public void putAll(Map<? extends K, ? extends V> map) 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 CacheStats stats() 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.
| |