K
- the type of the keys used to access data within this cacheV
- the type of the values held within this cachepublic interface Cache<K,V> extends java.lang.Iterable<Cache.Entry<K,V>>
Modifier and Type | Interface and Description |
---|---|
static interface |
Cache.Entry<K,V>
Represent a mapping of key to value held in a Cache
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all mapping currently present in the Cache without invoking the
CacheLoaderWriter or any
registered CacheEventListener instances
This is not an atomic operation and can potentially be very expensive |
boolean |
containsKey(K key)
Checks whether a mapping for the given key is present, without retrieving the associated value
|
V |
get(K key)
Retrieve the value currently mapped to the provided key
|
java.util.Map<K,V> |
getAll(java.util.Set<? extends K> keys)
Retrieves all values associated with the given keys.
|
CacheRuntimeConfiguration<K,V> |
getRuntimeConfiguration()
Exposes the
CacheRuntimeConfiguration associated with this Cache instance. |
void |
put(K key,
V value)
Associates the provided value to the given key
|
void |
putAll(java.util.Map<? extends K,? extends V> entries)
Associates all the provided key:value pairs.
|
V |
putIfAbsent(K key,
V value)
If the provided key is not associated with a value, then associate it with the provided value.
|
void |
remove(K key)
Removes the value, if any, associated with the provided key
|
boolean |
remove(K key,
V value)
If the provided key is associated with the provided value then remove the entry.
|
void |
removeAll(java.util.Set<? extends K> keys)
Removes any associates for the given keys.
|
V |
replace(K key,
V value)
If the provided key is associated with a value, then replace that value with the provided value.
|
boolean |
replace(K key,
V oldValue,
V newValue)
If the provided key is associated with
oldValue , then replace that value with newValue . |
V get(K key) throws CacheLoadingException
key
- the key to query the value forjava.lang.NullPointerException
- if the provided key is nullCacheLoadingException
- if the CacheLoaderWriter
associated with this cache was invoked and threw an Exception
void put(K key, V value) throws CacheWritingException
key
- the key, may not be nullvalue
- the value, may not be nulljava.lang.NullPointerException
- if either key or value is nullCacheWritingException
- if the CacheLoaderWriter
associated with this cache threw an Exception
while writing the value for the given key to underlying system of record.boolean containsKey(K key)
key
- the keyjava.lang.NullPointerException
- if the provided key is nullvoid remove(K key) throws CacheWritingException
key
- the key to remove the value forjava.lang.NullPointerException
- if the provided key is nullCacheWritingException
- if the CacheLoaderWriter
associated
with this cache threw an Exception
while removing the value for the
given key from the underlying system of record.java.util.Map<K,V> getAll(java.util.Set<? extends K> keys) throws BulkCacheLoadingException
keys
- keys to query fornull
if the key was not mappedjava.lang.NullPointerException
- if the Set
or any of the contained keys are null
.BulkCacheLoadingException
- if loading some or all values failedvoid putAll(java.util.Map<? extends K,? extends V> entries) throws BulkCacheWritingException
entries
- key:value pairs to associatejava.lang.NullPointerException
- if the Map
or any of the contained keys or values are null
.BulkCacheWritingException
- if the CacheLoaderWriter
associated with this cache threw an Exception
while writing given key:value pairs to underlying system of record.void removeAll(java.util.Set<? extends K> keys) throws BulkCacheWritingException
keys
- keys to remove values forjava.lang.NullPointerException
- if the Set
or any of the contained keys are null
.BulkCacheWritingException
- if the CacheLoaderWriter
associated with this cache threw an Exception
while removing mappings for given keys from underlying system of record.void clear()
CacheLoaderWriter
or any
registered CacheEventListener
instances
This is not an atomic operation and can potentially be very expensiveV putIfAbsent(K key, V value) throws CacheLoadingException, CacheWritingException
key
- the key to be associated withvalue
- the value to associatenull
if nonejava.lang.NullPointerException
- if either key or value is nullCacheLoadingException
- if the CacheLoaderWriter
associated with this cache was invoked and threw an Exception
while loading
the value for the keyCacheWritingException
- if the CacheLoaderWriter
associated with this cache threw an Exception
while writing the value for the given key to underlying system of record.boolean remove(K key, V value) throws CacheWritingException
key
- the key to removevalue
- the value to check againsttrue
if the entry was removedjava.lang.NullPointerException
- if either key or value is nullCacheWritingException
- if the CacheLoaderWriter
associated with this cache threw an Exception
while removing the given key:value mappingV replace(K key, V value) throws CacheLoadingException, CacheWritingException
key
- the key to be associated withvalue
- the value to associatenull
if nonejava.lang.NullPointerException
- if either key or value is nullCacheLoadingException
- if the CacheLoaderWriter
associated with this cache was invoked and threw an Exception
while loading
the value for the keyCacheWritingException
- if the CacheLoaderWriter
associated with this cache was invoked and threw an Exception
while replacing value for given key on underlying system of record.boolean replace(K key, V oldValue, V newValue) throws CacheLoadingException, CacheWritingException
oldValue
, then replace that value with newValue
.key
- the key to be associated witholdValue
- the value to check againstnewValue
- the value to associatetrue
if the value was replacedjava.lang.NullPointerException
- if any of the values, or the key is nullCacheLoadingException
- if the CacheLoaderWriter
associated with this cache was invoked and threw an Exception
while loading
the value for the keyCacheWritingException
- if the CacheLoaderWriter
associated with this cache was invoked and threw an Exception
while replacing value for given key on underlying system of record.CacheRuntimeConfiguration<K,V> getRuntimeConfiguration()
CacheRuntimeConfiguration
associated with this Cache instance.