K - the key typeV - the value type@PublicApi
public interface LocalCacheOperations<K,V>
| Modifier and Type | Method and Description |
|---|---|
Optional<V> |
get(K key)
Returns a value that is associated with a specified key.
|
V |
get(K key,
Supplier<? extends V> supplier)
Returns a value that may be associated with a specified key.
|
Map<K,V> |
getBulk(Function<Collection<K>,Map<K,V>> factory,
Iterable<K> keys)
Returns the values that are associated with the specified keys.
|
default Map<K,V> |
getBulk(Function<Collection<K>,Map<K,V>> factory,
K... keys)
Returns the values that are associated with the specified keys.
|
Map<K,Optional<V>> |
getBulk(Iterable<K> keys)
Returns the values that are associated with the specified keys.
|
default Map<K,Optional<V>> |
getBulk(K... keys)
Returns the values that are associated with the specified keys.
|
Optional<V> |
put(K key,
V value)
Unconditionally puts the value under the specified key, and returns the previous value associated
with the key (if one existed).
|
Optional<V> |
putIfAbsent(K key,
V value)
Conditionally puts the value under the specified key, if no entry currently exists.
|
void |
remove(Iterable<K> keys)
Removes all the entries for the supplied keys.
|
default void |
remove(K... keys)
Removes all the entries for the supplied keys.
|
void |
removeAll()
Removes all the entries in the cache.
|
boolean |
removeIf(K key,
V value)
Conditionally removed an entry for a specified key, iff:
An entry already exists for the key
The current value matches the supplied value using
Object.equals(Object)
|
boolean |
replaceIf(K key,
V currentValue,
V newValue)
Conditionally replaces the value associated with a key, iff:
An entry already exists for the key
The current value matches the supplied currentValue using
Object.equals(Object)
|
@Nonnull Optional<V> get(K key)
key - the key to check.Optional which may contain the value associated with the key.@Nonnull V get(K key, Supplier<? extends V> supplier)
Notes:
key - the key uniquely identifying the value to be retrievedsupplier - used to generate the value, if one does not exist already for the key. The supplier may not
return null.@Nonnull Optional<V> put(K key, V value)
key - the key to put the data undervalue - the value to associate with the key.Optional which may contain the previous value associated with the key.@Nonnull Optional<V> putIfAbsent(K key, V value)
key - the key to put the data undervalue - the value to associate with the key.Optional.EMPTY is no entry previously existed, otherwise the Optional contains
the current value.boolean replaceIf(K key, V currentValue, V newValue)
Object.equals(Object)key - the key to replace data undercurrentValue - the current value to matchnewValue - the replacement valueboolean removeIf(K key, V value)
Object.equals(Object)key - the key of the entry to remove conditionallyvalue - the current value to matchdefault void remove(K... keys)
remove(Iterable) passing
Arrays.asList(keys) as the argument.keys - specifies the entries to be removed.void remove(Iterable<K> keys)
keys - specifies the entries to be removed.void removeAll()
@Nonnull default Map<K,Optional<V>> getBulk(K... keys)
getBulk(Iterable) passing Arrays.asList(keys) as the parameter.@Nonnull Map<K,Optional<V>> getBulk(Iterable<K> keys)
@Nonnull default Map<K,V> getBulk(Function<Collection<K>,Map<K,V>> factory, K... keys)
getBulk(Function, Iterable) passing factory and Arrays.asList(keys) as the parameters.
Notes:
factory - used to generate the values for the keys that do not have entries. The factory must return a
map containing a non-null entry for each supplied key.keys - the keys to retrieveMap that is keyed on the keys specified. Each entry in the Map will have
the value associated with the key.@Nonnull Map<K,V> getBulk(Function<Collection<K>,Map<K,V>> factory, Iterable<K> keys)
Notes:
factory - used to generate the values for the keys that do not have entries. The factory must return a
map containing a non-null entry for each supplied key.keys - the keys to retrieveMap that is keyed on the keys specified. Each entry in the Map will have
the value associated with the key.Copyright © 2015 Atlassian. All rights reserved.