public class StatsCollectingCache<K,V> extends SimpleCacheImpl<K,V>
AdvancedCache
to collect statisticsSimpleCacheImpl.CacheEntryChange<K,V>, SimpleCacheImpl.CacheEntrySet, SimpleCacheImpl.EntrySet, SimpleCacheImpl.EntrySetBase<T extends Map.Entry<K,V>>, SimpleCacheImpl.KeySet, SimpleCacheImpl.ValueAndMetadata<V>, SimpleCacheImpl.Values
Constructor and Description |
---|
StatsCollectingCache(String cacheName) |
Modifier and Type | Method and Description |
---|---|
protected V |
computeIfAbsentInternal(K key,
Function<? super K,? extends V> mappingFunction,
ByRef<V> newValueRef) |
protected V |
computeIfPresentInternal(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
SimpleCacheImpl.CacheEntryChange<K,V> ref) |
protected V |
computeInternal(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
SimpleCacheImpl.CacheEntryChange<K,V> ref) |
void |
evict(K key)
Evicts an entry from the memory of the cache.
|
V |
get(Object key) |
Map<K,V> |
getAll(Set<?> keys)
Gets a collection of entries, returning them as
Map of the values associated with the set of keys
requested. |
Map<K,CacheEntry<K,V>> |
getAllCacheEntries(Set<?> keys)
Gets a collection of entries from the
AdvancedCache , returning them as Map of the cache entries
associated with the set of keys requested. |
Map<K,V> |
getAndPutAll(Map<? extends K,? extends V> entries)
Executes an equivalent of
Map.putAll(Map) , returning previous values of the modified entries. |
protected V |
getAndPutInternal(K key,
V value,
Metadata metadata) |
protected V |
getAndReplaceInternal(K key,
V value,
Metadata metadata) |
CacheEntry<K,V> |
getCacheEntry(Object k)
Retrieves a CacheEntry corresponding to a specific key.
|
Stats |
getStats()
Returns a
Stats object that allows several statistics associated with this cache at runtime. |
protected V |
mergeInternal(K key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction,
SimpleCacheImpl.CacheEntryChange<K,V> ref,
Metadata metadata) |
protected void |
putForExternalReadInternal(K key,
V value,
Metadata metadata,
ByRef.Boolean isCreatedRef) |
protected V |
putIfAbsentInternal(K key,
V value,
Metadata metadata) |
V |
remove(Object key)
If the return value of this operation will be ignored by the application,
the user is strongly encouraged to use the
Flag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently
as possible (i.e. |
boolean |
remove(Object key,
Object value) |
protected boolean |
replaceInternal(K key,
V oldValue,
V value,
Metadata metadata) |
String |
toString() |
AdvancedCache<K,V> |
with(ClassLoader classLoader) |
AdvancedCache<K,V> |
withFlags(Flag... flags)
A method that adds flags to any API call.
|
addFilteredListenerAsync, addListenerAsync, addListenerAsync, addStorageFormatFilteredListenerAsync, cacheEntrySet, checkExpiration, clear, clearAsync, compute, compute, compute, compute, computeAsync, computeAsync, computeAsync, computeAsync, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresent, computeIfPresent, computeIfPresent, computeIfPresent, computeIfPresentAsync, computeIfPresentAsync, computeIfPresentAsync, computeIfPresentAsync, containsKey, containsValue, endBatch, entrySet, forEach, getAdvancedCache, getAllAsync, getAsync, getAsyncInterceptorChain, getAuthorizationManager, getAvailability, getBatchContainer, getCacheConfiguration, getCacheEntryAsync, getCacheManager, getCacheName, getCacheStatus, getClassLoader, getComponentRegistry, getConfigurationAsProperties, getDataContainer, getDistributionManager, getEvictionManager, getExpirationManager, getGroup, getKeyDataConversion, getListeners, getLockManager, getName, getRpcManager, getStatus, getStreamSupplier, getTransactionManager, getValueDataConversion, getVersion, getXAResource, isEmpty, keySet, lock, lock, lockAs, lockedStream, merge, merge, merge, merge, mergeAsync, mergeAsync, mergeAsync, mergeAsync, noFlags, put, put, put, put, putAll, putAll, putAll, putAll, putAllAsync, putAllAsync, putAllAsync, putAllAsync, putAllInternal, putAsync, putAsync, putAsync, putAsync, putForExternalRead, putForExternalRead, putForExternalRead, putForExternalRead, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, removeAsync, removeAsync, removeGroup, removeLifespanExpired, removeListenerAsync, removeMaxIdleExpired, replace, replace, replace, replace, replace, replace, replace, replace, replaceAll, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, setAvailability, size, sizeAsync, start, startBatch, stop, transform, values, withEncoding, withEncoding, withFlags, withKeyEncoding, withMediaType, withStorageMediaType, withSubject, withWrapping, withWrapping
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
compute, computeAsync, computeIfAbsent, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, merge, mergeAsync, withFlags
compute, compute, compute, computeAsync, computeAsync, computeAsync, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, merge, merge, merge, mergeAsync, mergeAsync, mergeAsync, shutdown
containsKeyAsync
getOrDefault
addFilteredListener, addListener, addStorageFormatFilteredListener
addListener, removeListener
public StatsCollectingCache(String cacheName)
public AdvancedCache<K,V> withFlags(Flag... flags)
AdvancedCache
cache.withFlags(Flag.FORCE_WRITE_LOCK).get(key);will invoke a cache.get() with a write lock forced. Note that for the flag to take effect, the cache operation must be invoked on the instance returned by this method. As an alternative to setting this on every invocation, users should also consider saving the decorated cache, as this allows for more readable code. E.g.:
AdvancedCache<?, ?> forceWriteLockCache = cache.withFlags(Flag.FORCE_WRITE_LOCK); forceWriteLockCache.get(key1); forceWriteLockCache.get(key2); forceWriteLockCache.get(key3);
withFlags
in interface AdvancedCache<K,V>
withFlags
in class SimpleCacheImpl<K,V>
flags
- a set of flags to apply. See the Flag
documentation.AdvancedCache
instance on which a real operation is to be invoked, if the flags are to be
applied.public AdvancedCache<K,V> with(ClassLoader classLoader)
with
in interface AdvancedCache<K,V>
with
in class SimpleCacheImpl<K,V>
public Stats getStats()
AdvancedCache
Stats
object that allows several statistics associated with this cache at runtime.getStats
in interface AdvancedCache<K,V>
getStats
in class SimpleCacheImpl<K,V>
Stats
objectpublic CacheEntry<K,V> getCacheEntry(Object k)
AdvancedCache
getCacheEntry
in interface AdvancedCache<K,V>
getCacheEntry
in class SimpleCacheImpl<K,V>
k
- the key whose associated cache entry is to be returnednull
if this map contains no mapping for
the keypublic Map<K,V> getAll(Set<?> keys)
AdvancedCache
Map
of the values associated with the set of keys
requested.
If the cache is configured read-through, and a get for a key would return null because an entry is missing from
the cache, the Cache's CacheLoader
is called in an attempt to load the entry. If an entry cannot be loaded
for a given key, the returned Map will contain null for value of the key.
Unlike other bulk methods if this invoked in an existing transaction all entries will be stored in the current transactional context
The returned Map
will be a copy and updates to the map will not be reflected in the Cache and vice versa.
The keys and values themselves however may not be copies depending on if storeAsBinary is enabled and the value
was retrieved from the local node.
getAll
in interface AdvancedCache<K,V>
getAll
in class SimpleCacheImpl<K,V>
keys
- The keys whose associated values are to be returned.public Map<K,CacheEntry<K,V>> getAllCacheEntries(Set<?> keys)
AdvancedCache
AdvancedCache
, returning them as Map
of the cache entries
associated with the set of keys requested.
If the cache is configured read-through, and a get for a key would return null because an entry is missing from
the cache, the Cache's CacheLoader
is called in an attempt to load the entry. If an entry cannot be loaded
for a given key, the returned Map will contain null for value of the key.
Unlike other bulk methods if this invoked in an existing transaction all entries will be stored in the current transactional context
The returned Map
will be a copy and updates to the map will not be reflected in the Cache and vice versa.
The keys and values themselves however may not be copies depending on if storeAsBinary is enabled and the value
was retrieved from the local node.
getAllCacheEntries
in interface AdvancedCache<K,V>
getAllCacheEntries
in class SimpleCacheImpl<K,V>
keys
- The keys whose associated values are to be returned.public Map<K,V> getAndPutAll(Map<? extends K,? extends V> entries)
AdvancedCache
Map.putAll(Map)
, returning previous values of the modified entries.entries
- mappings to be stored in this mappublic void evict(K key)
Cache
BasicCache.remove(Object)
to remove an
entry from the entire cache system.
This method is designed to evict an entry from memory to free up memory used by the application. This method uses
a 0 lock acquisition timeout so it does not block in attempting to acquire locks. It behaves as a no-op if the
lock on the entry cannot be acquired immediately.
Important: this method should not be called from within a transaction scope.protected V getAndPutInternal(K key, V value, Metadata metadata)
getAndPutInternal
in class SimpleCacheImpl<K,V>
protected V getAndReplaceInternal(K key, V value, Metadata metadata)
getAndReplaceInternal
in class SimpleCacheImpl<K,V>
protected void putForExternalReadInternal(K key, V value, Metadata metadata, ByRef.Boolean isCreatedRef)
putForExternalReadInternal
in class SimpleCacheImpl<K,V>
protected V putIfAbsentInternal(K key, V value, Metadata metadata)
putIfAbsentInternal
in class SimpleCacheImpl<K,V>
public V remove(Object key)
BasicCache
Flag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently
as possible (i.e. avoiding needless remote or network calls).protected boolean replaceInternal(K key, V oldValue, V value, Metadata metadata)
replaceInternal
in class SimpleCacheImpl<K,V>
protected V computeIfAbsentInternal(K key, Function<? super K,? extends V> mappingFunction, ByRef<V> newValueRef)
computeIfAbsentInternal
in class SimpleCacheImpl<K,V>
protected V computeIfPresentInternal(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, SimpleCacheImpl.CacheEntryChange<K,V> ref)
computeIfPresentInternal
in class SimpleCacheImpl<K,V>
protected V computeInternal(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, SimpleCacheImpl.CacheEntryChange<K,V> ref)
computeInternal
in class SimpleCacheImpl<K,V>
protected V mergeInternal(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, SimpleCacheImpl.CacheEntryChange<K,V> ref, Metadata metadata)
mergeInternal
in class SimpleCacheImpl<K,V>
public String toString()
toString
in class SimpleCacheImpl<K,V>
Copyright © 2021 JBoss by Red Hat. All rights reserved.