K
- the key typeV
- the value typepublic interface CachingTier<K,V> extends ConfigurationChangeSupport
AuthoritativeTier
.
As soon as there is more than one tier in a Store
, one will be the AuthoritativeTier
while others
will be regrouped under the CachingTier
Modifier and Type | Interface and Description |
---|---|
static interface |
CachingTier.InvalidationListener<K,V>
Caching tier invalidation listener.
|
static interface |
CachingTier.Provider
Service interface for providing CachingTier instances. |
Modifier and Type | Method and Description |
---|---|
java.util.Map<K,Store.ValueHolder<V>> |
bulkGetOrComputeIfAbsent(java.lang.Iterable<? extends K> keys,
java.util.function.Function<java.util.Set<? extends K>,java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends Store.ValueHolder<V>>>> mappingFunction)
Bulk method which takes
Set of keys as argument and returns a Map of its mapped value from CachingTier,
For all the missing entries from CachingTier using mappingFunction to compute its value |
void |
clear()
Empty out the caching tier.
|
Store.ValueHolder<V> |
getOrComputeIfAbsent(K key,
java.util.function.Function<K,Store.ValueHolder<V>> source)
Either return the value holder currently in the caching tier, or compute and store it when it isn't present.
|
Store.ValueHolder<V> |
getOrDefault(K key,
java.util.function.Function<K,Store.ValueHolder<V>> source)
Either return the value holder currently in the caching tier, or return the provided default.
|
void |
invalidate(K key)
Removes a mapping, triggering the
CachingTier.InvalidationListener if registered. |
void |
invalidateAll()
Empties the
CachingTier , triggering the CachingTier.InvalidationListener if registered. |
void |
invalidateAllWithHash(long hash)
Remove all mappings whose key have the specified hash code from the
CachingTier , triggering the
CachingTier.InvalidationListener if registered. |
void |
setInvalidationListener(CachingTier.InvalidationListener<K,V> invalidationListener)
Set the caching tier's
CachingTier.InvalidationListener . |
getConfigurationChangeListeners
Store.ValueHolder<V> getOrComputeIfAbsent(K key, java.util.function.Function<K,Store.ValueHolder<V>> source) throws StoreAccessException
Note that in case of expired value holders, null
will be returned and the mapping will be invalidated.
key
- the keysource
- the function that computes the value when absent from this tiernull
StoreAccessException
- if the mapping cannot be retrieved or storedStore.ValueHolder<V> getOrDefault(K key, java.util.function.Function<K,Store.ValueHolder<V>> source) throws StoreAccessException
Note that in case of expired value holders, null
will be returned and the mapping will be invalidated.
key
- the keysource
- the function that computes the default value when absent from this tiernull
StoreAccessException
- if the mapping cannot be retrieved or storedvoid invalidate(K key) throws StoreAccessException
CachingTier.InvalidationListener
if registered.key
- the key to removeStoreAccessException
- if the mapping cannot be removedvoid invalidateAll() throws StoreAccessException
CachingTier
, triggering the CachingTier.InvalidationListener
if registered.StoreAccessException
- if mappings cannot be removedvoid invalidateAllWithHash(long hash) throws StoreAccessException
CachingTier
, triggering the
CachingTier.InvalidationListener
if registered.StoreAccessException
- if mappings cannot be removedvoid clear() throws StoreAccessException
Note that this operation is not atomic.
StoreAccessException
- if mappings cannot be removedvoid setInvalidationListener(CachingTier.InvalidationListener<K,V> invalidationListener)
CachingTier.InvalidationListener
.invalidationListener
- the listenerjava.util.Map<K,Store.ValueHolder<V>> bulkGetOrComputeIfAbsent(java.lang.Iterable<? extends K> keys, java.util.function.Function<java.util.Set<? extends K>,java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends Store.ValueHolder<V>>>> mappingFunction) throws StoreAccessException
Set
of keys
as argument and returns a Map
of its mapped value from CachingTier,
For all the missing entries from CachingTier using mappingFunction
to compute its value
The function takes an Iterable
of missing keys, where each entry's mapping is missing from CachingTier.
It is expected that the function should return an Iterable
of Map.Entry
key/value pairs containing an entry for each key that was passed to it.
Note: This method guarantees atomicity of computations for each individual key in keys
. Implementations may choose to provide coarser grained atomicity.
keys
- the keys to compute a new value for, if they're not in the store.mappingFunction
- the function that generates new values.Map
of key/value pairs for each key in keys
.StoreAccessException
- when a failure occurs when accessing the store.