| Constructor and Description |
|---|
GuavaJvmCache(String name,
JvmCacheSettings settings)
Creates an instance.
|
| 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<Set<K>,Map<K,V>> factory,
Iterable<K> keys)
Returns the values that are associated with the specified keys.
|
Map<K,V> |
getBulk(Function<Set<K>,Map<K,V>> factory,
K... keys)
Returns the values that are associated with the specified keys.
|
Set<K> |
getKeys()
Gets the keys of all objects currently stored in the cache.
|
String |
getName()
The name of the cache, uniquely identifies this cache.
|
void |
put(K key,
V value)
Unconditionally puts the value under the specified key.
|
Optional<V> |
putIfAbsent(K key,
V value)
Conditionally puts the value under the specified key, if no entry currently exists.
|
void |
remove(K key)
Removes the entries for the supplied key.
|
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)
|
public GuavaJvmCache(String name, JvmCacheSettings settings)
name - the name of the cachesettings - the settings for the cache.public Set<K> getKeys()
JvmCachepublic Optional<V> get(K key)
LocalCacheOperationsget in interface LocalCacheOperations<K,V>key - the key to check.Optional which may contain the value associated with the key.public V get(K key, Supplier<? extends V> supplier)
LocalCacheOperationsNotes:
get in interface LocalCacheOperations<K,V>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.@SafeVarargs public final Map<K,V> getBulk(Function<Set<K>,Map<K,V>> factory, K... keys)
LocalCacheOperationsLocalCacheOperations.getBulk(Function, Iterable) passing factory and Arrays.asList(keys) as the parameters.getBulk in interface LocalCacheOperations<K,V>factory - used to generate the values for the keys that do not have entries. The factory must return a
map containing only a non-null value for each supplied key. Extra keys are not allowed.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.LocalCacheOperations.getBulk(Function, Iterable)public Map<K,V> getBulk(Function<Set<K>,Map<K,V>> factory, Iterable<K> keys)
LocalCacheOperationsNotes:
LocalCacheOperations.remove(Object) or LocalCacheOperations.removeIf(Object, Object). Caller beware.
getBulk in interface LocalCacheOperations<K,V>factory - used to generate the values for the keys that do not have entries. The factory must return a
map containing only a non-null value for each supplied key. Extra keys are not allowed.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.public void put(K key, V value)
LocalCacheOperationsput in interface LocalCacheOperations<K,V>key - the key to put the data undervalue - the value to associate with the key.public Optional<V> putIfAbsent(K key, V value)
LocalCacheOperationsputIfAbsent in interface LocalCacheOperations<K,V>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.public boolean replaceIf(K key, V currentValue, V newValue)
LocalCacheOperationsObject.equals(Object)replaceIf in interface LocalCacheOperations<K,V>key - the key to replace data undercurrentValue - the current value to matchnewValue - the replacement valuepublic void remove(K key)
LocalCacheOperationsremove in interface LocalCacheOperations<K,V>key - the key of the entry to removepublic void removeAll()
LocalCacheOperationsremoveAll in interface LocalCacheOperations<K,V>public boolean removeIf(K key, V value)
LocalCacheOperationsObject.equals(Object)removeIf in interface LocalCacheOperations<K,V>key - the key of the entry to remove conditionallyvalue - the current value to matchCopyright © 2016 Atlassian. All rights reserved.