|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ehcache.internal.store.offheap.AbstractOffHeapStore<K,V>
public abstract class AbstractOffHeapStore<K,V>
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.ehcache.spi.cache.tiering.AuthoritativeTier |
|---|
AuthoritativeTier.Provider |
| Nested classes/interfaces inherited from interface org.ehcache.spi.cache.Store |
|---|
Store.Configuration<K,V>, Store.Iterator<T>, Store.PersistentStoreConfiguration<K,V,T>, Store.ValueHolder<V> |
| Nested classes/interfaces inherited from interface org.ehcache.spi.cache.tiering.LowerCachingTier |
|---|
LowerCachingTier.Provider |
| Field Summary | |
|---|---|
protected org.ehcache.internal.store.offheap.AbstractOffHeapStore.BackingMapEvictionListener<K,V> |
mapEvictionListener
|
| Constructor Summary | |
|---|---|
AbstractOffHeapStore(java.lang.String statisticsTag,
Store.Configuration<K,V> config,
TimeSource timeSource)
|
|
| Method Summary | ||
|---|---|---|
protected abstract EhcacheOffHeapBackingMap<K,OffHeapValueHolder<V>> |
backingMap()
|
|
java.util.Map<K,Store.ValueHolder<V>> |
bulkCompute(java.util.Set<? extends K> keys,
Function<java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>,java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>> remappingFunction)
Compute a value for every key passed in the Set keys argument, using the remappingFunction to compute the value. |
|
java.util.Map<K,Store.ValueHolder<V>> |
bulkCompute(java.util.Set<? extends K> keys,
Function<java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>,java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>> remappingFunction,
NullaryFunction<java.lang.Boolean> replaceEqual)
Compute a value for every key passed in the Set keys argument, using the remappingFunction to compute the value. |
|
java.util.Map<K,Store.ValueHolder<V>> |
bulkComputeIfAbsent(java.util.Set<? extends K> keys,
Function<java.lang.Iterable<? extends K>,java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>> mappingFunction)
Compute a value for every key passed in the Set keys argument using the mappingFunction
to compute the value. |
|
void |
clear()
Removes all of the mappings from this map. |
|
Store.ValueHolder<V> |
compute(K key,
BiFunction<? super K,? super V,? extends V> mappingFunction)
Compute the value for the given key by invoking the given function to produce the value. |
|
Store.ValueHolder<V> |
compute(K key,
BiFunction<? super K,? super V,? extends V> mappingFunction,
NullaryFunction<java.lang.Boolean> replaceEqual)
Compute the value for the given key by invoking the given function to produce the value. |
|
Store.ValueHolder<V> |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction)
Compute the value for the given key (only if absent or expired) by invoking the given function to produce the value. |
|
Store.ValueHolder<V> |
computeIfAbsentAndFault(K key,
Function<? super K,? extends V> mappingFunction)
Marks the mapping as not evictable and performs computeIfAbsent() atomically. |
|
Store.ValueHolder<V> |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction)
Compute the value for the given key (only if present and non-expired) by invoking the given function to produce the value. |
|
Store.ValueHolder<V> |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
NullaryFunction<java.lang.Boolean> replaceEqual)
Compute the value for the given key (only if present and non-expired) by invoking the given function to produce the value. |
|
boolean |
containsKey(K key)
Returns true if this store contains the specified key and the entry is not expired. |
|
void |
disableStoreEventNotifications()
Disables store event notifications. |
|
void |
enableStoreEventNotifications(StoreEventListener<K,V> listener)
Enables notifications for store-initiated events, i.e. |
|
boolean |
flush(K key,
Store.ValueHolder<V> valueFlushed)
This marks the entry as evictable again. |
|
Store.ValueHolder<V> |
get(K key)
Returns the ValueHolder to
which the specified key is mapped, or null if this store contains no
mapping for the key or if it was evicted (or became expired) since it was
initially installed. |
|
Store.ValueHolder<V> |
getAndFault(K key)
Marks the mapping as not evictable and returns it atomically. |
|
Store.ValueHolder<V> |
getAndRemove(K key)
Return the value holder currently in the caching tier and remove it. |
|
Store.ValueHolder<V> |
getOrComputeIfAbsent(K key,
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. |
|
void |
handleOversizeMappingException(K key,
org.terracotta.offheapstore.exceptions.OversizeMappingException cause)
|
|
void |
handleOversizeMappingException(K key,
org.terracotta.offheapstore.exceptions.OversizeMappingException cause,
java.util.concurrent.atomic.AtomicBoolean invokeValve)
|
|
void |
invalidate(K key)
Remove a mapping. |
|
void |
invalidate(K key,
NullaryFunction<K> function)
Remove a mapping, then call a function under the same lock scope irrespectively of a mapping being there or not. |
|
Store.Iterator<Cache.Entry<K,Store.ValueHolder<V>>> |
iterator()
Returns an iterator over the elements in this store. |
|
void |
put(K key,
V value)
Maps the specified key to the specified value in this store. |
|
Store.ValueHolder<V> |
putIfAbsent(K key,
V value)
Maps the specified key to the specified value in this store, unless a non-expired mapping already exists. |
|
void |
registerEmergencyValve(java.util.concurrent.Callable<java.lang.Void> valve)
|
|
void |
remove(K key)
Removes the key (and its corresponding value) from this store. |
|
boolean |
remove(K key,
V value)
Removes the entry for a key only if currently mapped to a given value and the entry is not expired This is equivalent to |
|
Store.ValueHolder<V> |
replace(K key,
V value)
Replaces the entry for a key only if currently mapped to some value and the entry is not expired. |
|
boolean |
replace(K key,
V oldValue,
V newValue)
Replaces the entry for a key only if currently mapped to a given value and the entry is not expired. |
|
void |
setInvalidationListener(CachingTier.InvalidationListener<K,V> invalidationListener)
Set the caching tier's invalidation listener. |
|
protected static
|
wrap(EvictionVeto<? super K,? super V> delegate,
TimeSource timeSource)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.ehcache.spi.cache.ConfigurationChangeSupport |
|---|
getConfigurationChangeListeners |
| Field Detail |
|---|
protected org.ehcache.internal.store.offheap.AbstractOffHeapStore.BackingMapEvictionListener<K,V> mapEvictionListener
| Constructor Detail |
|---|
public AbstractOffHeapStore(java.lang.String statisticsTag,
Store.Configuration<K,V> config,
TimeSource timeSource)
| Method Detail |
|---|
public Store.ValueHolder<V> get(K key)
StoreValueHolder to
which the specified key is mapped, or null if this store contains no
mapping for the key or if it was evicted (or became expired) since it was
initially installed.
More formally, if this store contains a non-expired mapping from a key
k to a ValueHolder
v such that key.equals(k),
then this method returns v; otherwise it returns
null. (There can be at most one such mapping.)
get in interface Store<K,V>public boolean containsKey(K key)
Store
containsKey in interface Store<K,V>key - key whose presence in this store is to be tested
public void put(K key,
V value)
throws CacheAccessException
Storeget method
with a key that is equal to the original key.
put in interface Store<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified key
CacheAccessException - if the mapping can't be installed
public Store.ValueHolder<V> putIfAbsent(K key,
V value)
throws java.lang.NullPointerException,
CacheAccessException
Store
if (!store.containsKey(key))
store.put(key, value);
return null;
else
return store.get(key);
except that the action is performed atomically.
The ValueHolder can be retrieved by calling the get method
with a key that is equal to the original key.
Neither the key nor the value can be null.
putIfAbsent in interface Store<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified key
ValueHolder to
which the specified key was previously mapped, or null if no such mapping existed or the mapping was expired
java.lang.NullPointerException - if the specified key or value is null
CacheAccessException - if the mapping can't be installedpublic void remove(K key)
Store
remove in interface Store<K,V>key - the key that needs to be removed
public boolean remove(K key,
V value)
throws java.lang.NullPointerException
Store
if (store.containsKey(key) && store.get(key).equals(value)) {
store.remove(key);
return true;
} else return false;
except that the action is performed atomically.
remove in interface Store<K,V>key - key with which the specified value is associatedvalue - value expected to be associated with the specified key
java.lang.NullPointerException - if the specified key or value is null
public Store.ValueHolder<V> replace(K key,
V value)
throws java.lang.NullPointerException,
CacheAccessException
Store
V oldValue = store.get(key);
if (oldValue != null) {
map.put(key, value);
}
return oldValue;
except that the action is performed atomically.
replace in interface Store<K,V>key - key with which the specified value is associatedvalue - value expected to be associated with the specified key
ValueHolder to
which the specified key was previously mapped, or null if no such mapping existed
java.lang.NullPointerException - if the specified key or value is null
CacheAccessException - if the mapping can't be replaced
public boolean replace(K key,
V oldValue,
V newValue)
throws java.lang.NullPointerException,
java.lang.IllegalArgumentException,
CacheAccessException
Store
if (store.containsKey(key) && store.get(key).equals(oldValue)) {
store.put(key, newValue);
return true;
} else return false;
except that the action is performed atomically.
replace in interface Store<K,V>key - key with which the specified value is associatedoldValue - value expected to be associated with the specified keynewValue - value to be associated with the specified key
java.lang.NullPointerException - if the specified key or value is null
CacheAccessException - if the mapping can't be replaced
java.lang.IllegalArgumentException
public void clear()
throws CacheAccessException
Store
clear in interface Store<K,V>clear in interface LowerCachingTier<K,V>CacheAccessException - if the store couldn't be partially or entirely be cleared.public void enableStoreEventNotifications(StoreEventListener<K,V> listener)
Store
enableStoreEventNotifications in interface Store<K,V>listener - listener to notifypublic void disableStoreEventNotifications()
Store
disableStoreEventNotifications in interface Store<K,V>
public Store.Iterator<Cache.Entry<K,Store.ValueHolder<V>>> iterator()
throws CacheAccessException
Store
iterator in interface Store<K,V>CacheAccessException
public Store.ValueHolder<V> compute(K key,
BiFunction<? super K,? super V,? extends V> mappingFunction)
throws CacheAccessException
StoreStore.compute(Object, BiFunction, NullaryFunction)
with a "replaceEquals" function that returns Boolean.TRUE
compute in interface Store<K,V>CacheAccessException
public Store.ValueHolder<V> compute(K key,
BiFunction<? super K,? super V,? extends V> mappingFunction,
NullaryFunction<java.lang.Boolean> replaceEqual)
throws CacheAccessException
Store
compute in interface Store<K,V>key - the key to operate onmappingFunction - the function that will produce the value. The function will be supplied
with the key and existing value (or null if no entry exists) as parameters. The function should
return the desired new value for the entry or null to remove the entry. If the method throws
an unchecked exception the Store will not be modified (the caller will receive the exception)replaceEqual - If the existing value in the store is Object.equals(Object) to
the value returned from the mappingFunction this function will be invoked. If this function
returns Boolean.FALSE then the existing entry in the store will not be replaced
with a new entry and the existing entry will have its access time updated
CacheAccessException
public Store.ValueHolder<V> computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction)
throws CacheAccessException
Store
computeIfAbsent in interface Store<K,V>key - the key to operate onmappingFunction - the function that will produce the value. The function will be supplied
with the key as a parameter. The function return the desired new value for the entry or null to
remove the entry. If the method throws an unchecked exception the Store will not be modified
(the caller will receive the exception)
CacheAccessException
public Store.ValueHolder<V> computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction)
throws CacheAccessException
Store
This is equivalent to calling Store.computeIfPresent(Object, BiFunction, NullaryFunction)
with a "replaceEquals" function that returns Boolean.TRUE
computeIfPresent in interface Store<K,V>CacheAccessException
public Store.ValueHolder<V> computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
NullaryFunction<java.lang.Boolean> replaceEqual)
throws CacheAccessException
Store
computeIfPresent in interface Store<K,V>key - the key to operate onremappingFunction - the function that will produce the value. The function will be supplied
with the key and existing value as parameters. The function should
return the desired new value for the entry or null to remove the entry. If the method throws
an unchecked exception the Store will not be modified (the caller will receive the exception)replaceEqual - If the existing value in the store is Object.equals(Object) to
the value returned from the mappingFunction this function will be invoked. If this function
returns Boolean.FALSE then the existing entry in the store will not be replaced
with a new entry and the existing entry will have its access time updated
CacheAccessException
public java.util.Map<K,Store.ValueHolder<V>> bulkCompute(java.util.Set<? extends K> keys,
Function<java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>,java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>> remappingFunction)
throws CacheAccessException
StoreSet keys argument, using the remappingFunction to compute the value.
This is equivalent to calling Store.bulkCompute(Set, Function, NullaryFunction)
with a "replaceEquals" function that returns Boolean.TRUE
bulkCompute in interface Store<K,V>CacheAccessException
public java.util.Map<K,Store.ValueHolder<V>> bulkCompute(java.util.Set<? extends K> keys,
Function<java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>,java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>> remappingFunction,
NullaryFunction<java.lang.Boolean> replaceEqual)
throws CacheAccessException
StoreSet keys argument, using the remappingFunction to compute the value.
The function gets an Iterable of Map.Entry key/value pairs, where each entry's value is its currently stored value,
or null if nothing is stored under the key. It is expected that the function returns an Iterable of Map.Entry
key/value pairs containing an entry for each key that was passed to it. This returned Iterable should also iterate in the same order as the input Iterable.
If an entry's value is null, its mapping will be removed from the store.
bulkCompute call, depending on how the store wants or does not want to batch computations.
Note: This method guarantees atomicity of computations for each individual key in keys. Implementations may choose to provide coarser grained atomicity.
bulkCompute in interface Store<K,V>keys - the keys to compute a new value for.remappingFunction - the function that generates new values.replaceEqual - If the existing value in the store is Object.equals(Object) to
the value returned from the mappingFunction this function will be invoked. If this function
returns Boolean.FALSE then the existing entry in the store will not be replaced
with a new entry and the existing entry will have its access time updated
Map of key/value pairs for each key in keys to the value computed.
CacheAccessException
public java.util.Map<K,Store.ValueHolder<V>> bulkComputeIfAbsent(java.util.Set<? extends K> keys,
Function<java.lang.Iterable<? extends K>,java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>>> mappingFunction)
throws CacheAccessException
StoreSet keys argument using the mappingFunction
to compute the value.
The function gets an Iterable of Map.Entry key/value pairs, where each entry's value is its currently stored value
for each key that is not mapped in the store. It is expected that the function returns an Iterable of Map.Entry
key/value pairs containing an entry for each key that was passed to it. This returned Iterable should also iterate in the same order as the input Iterable.
The function may be called multiple times per bulkComputeIfAbsent call, depending on how the store wants or does not want to batch computations.
Note: This method guarantees atomicity of computations for each individual key in keys. Implementations may choose to provide coarser grained atomicity.
bulkComputeIfAbsent in interface Store<K,V>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 to the previously missing value.
CacheAccessException
public Store.ValueHolder<V> getAndFault(K key)
throws CacheAccessException
AuthoritativeTier
getAndFault in interface AuthoritativeTier<K,V>CacheAccessException - if the mapping can't be retrieved or updated.
public Store.ValueHolder<V> computeIfAbsentAndFault(K key,
Function<? super K,? extends V> mappingFunction)
throws CacheAccessException
AuthoritativeTier
computeIfAbsentAndFault in interface AuthoritativeTier<K,V>CacheAccessException - if the mapping can't be retrieved or updated.
public boolean flush(K key,
Store.ValueHolder<V> valueFlushed)
AuthoritativeTier
flush in interface AuthoritativeTier<K,V>public void setInvalidationListener(CachingTier.InvalidationListener<K,V> invalidationListener)
LowerCachingTier
setInvalidationListener in interface LowerCachingTier<K,V>invalidationListener - the listener.
public void invalidate(K key)
throws CacheAccessException
LowerCachingTier
invalidate in interface LowerCachingTier<K,V>key - the key.
CacheAccessException
public void invalidate(K key,
NullaryFunction<K> function)
throws CacheAccessException
LowerCachingTier
invalidate in interface LowerCachingTier<K,V>key - the key.function - the function to call.
CacheAccessException
public Store.ValueHolder<V> getAndRemove(K key)
throws CacheAccessException
getAndRemove in interface LowerCachingTier<K,V>key - the key.
CacheAccessException
public Store.ValueHolder<V> getOrComputeIfAbsent(K key,
Function<K,Store.ValueHolder<V>> source)
throws CacheAccessException
getOrComputeIfAbsent in interface LowerCachingTier<K,V>key - the key.source - the function that computes the value.
CacheAccessExceptionpublic void registerEmergencyValve(java.util.concurrent.Callable<java.lang.Void> valve)
public void handleOversizeMappingException(K key,
org.terracotta.offheapstore.exceptions.OversizeMappingException cause)
throws CacheAccessException
CacheAccessException
public void handleOversizeMappingException(K key,
org.terracotta.offheapstore.exceptions.OversizeMappingException cause,
java.util.concurrent.atomic.AtomicBoolean invokeValve)
throws CacheAccessException
CacheAccessExceptionprotected abstract EhcacheOffHeapBackingMap<K,OffHeapValueHolder<V>> backingMap()
protected static <K,V> Predicate<java.util.Map.Entry<K,OffHeapValueHolder<V>>> wrap(EvictionVeto<? super K,? super V> delegate,
TimeSource timeSource)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||