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 |
---|---|
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 listener