K
- the type of the cache entry keysV
- the type of the cache entry valuespublic class WrapperNamedCache<K,V> extends WrapperConcurrentMap<K,V> implements NamedCache<K,V>
WrapperConcurrentMap.Lock
WrapperObservableMap.InternalListener
AbstractKeySetBasedMap.EntrySet, AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection
AbstractKeyBasedMap.DeferredCacheEvent<K,V>
Base.LoggingWriter, Base.StackFrame
NamedCache.Option
QueryMap.Entry<K,V>
InvocableMap.Entry<K,V>, InvocableMap.EntryAggregator<K,V,R>, InvocableMap.EntryProcessor<K,V,R>, InvocableMap.ParallelAwareAggregator<K,V,P,R>, InvocableMap.StreamingAggregator<K,V,P,R>
Modifier and Type | Field and Description |
---|---|
protected CacheService |
m_service
The CacheService this NamedCache is a part of.
|
protected String |
m_sName
The name of the cache.
|
m_cWaitMillis, m_fEnforceLocking, m_gateMap, m_mapLock
m_fDeferredEvent, m_fTranslateEvents, m_listenerInternal, m_listenerSupport, m_map, m_stats
LOG_ALWAYS, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_US
EXPIRY_DEFAULT, EXPIRY_NEVER
LOCK_ALL
Constructor and Description |
---|
WrapperNamedCache(Map<K,V> map, String sName)
Construct a NamedCache wrapper based on the specified map.
|
WrapperNamedCache(Map<K,V> map, String sName, CacheService service)
Construct a NamedCache wrapper based on the specified map.
|
WrapperNamedCache(String sName)
Construct a NamedCache wrapper for an empty HashMap.
|
Modifier and Type | Method and Description |
---|---|
<T,E> void |
addIndex(ValueExtractor<? super T,? extends E> extractor, boolean fOrdered, Comparator<? super E> comparator)
Add an index to this QueryMap.
|
<R> R |
aggregate(Collection<? extends K> collKeys, InvocableMap.EntryAggregator<? super K,? super V,R> agent)
Perform an aggregating operation against the entries specified by the passed keys.
|
<R> R |
aggregate(Filter filter, InvocableMap.EntryAggregator<? super K,? super V,R> agent)
Perform an aggregating operation against the set of entries that are selected by the given Filter.
|
void |
destroy()
Release and destroy this instance of NamedCache.
|
Set<Map.Entry<K,V>> |
entrySet(Filter filter)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.
|
Set<Map.Entry<K,V>> |
entrySet(Filter filter, Comparator comparator)
Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter.
|
Map<K,V> |
getAll(Collection<? extends K> colKeys)
Get all the specified keys, if they are in the Map.
|
String |
getCacheName()
Return the cache name.
|
CacheService |
getCacheService()
Return the CacheService that this NamedCache is a part of.
|
<R> R |
invoke(K key, InvocableMap.EntryProcessor<K,V,R> agent)
Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation.
|
<R> Map<K,R> |
invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> agent)
Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each.
|
<R> Map<K,R> |
invokeAll(Filter filter, InvocableMap.EntryProcessor<K,V,R> agent)
Invoke the passed EntryProcessor against the set of entries that are selected by the given Filter, returning the result of the invocation for each.
|
boolean |
isActive()
Specifies whether or not the NamedCache is active.
|
boolean |
isDestroyed()
Specifies whether or not the NamedCache has been destroyed.
|
boolean |
isReleased()
Specifies whether or not the NamedCache has been released.
|
Set<K> |
keySet(Filter filter)
Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter.
|
V |
put(K oKey, V oValue, long cMillis)
Associates the specified value with the specified key in this cache and allows to specify an expiry for the cache entry.
|
void |
release()
Release local resources associated with this instance of NamedCache.
|
<T,E> void |
removeIndex(ValueExtractor<? super T,? extends E> extractor)
Remove an index from this QueryMap.
|
void |
truncate()
Removes all mappings from this map.
|
clear, getDescription, getLockDescription, getWaitMillis, instantiateLock, isInternalKeySetIteratorMutable, isLockingEnforced, lock, lock, put, putAll, remove, removeBlind, setLockingEnforced, setWaitMillis, toString, unlock
addMapListener, addMapListener, addMapListener, containsValue, dispatchEvent, dispatchPendingEvent, ensureInternalListener, ensureMapListenerSupport, get, getCacheStatistics, getInternalKeySet, getMap, getMapListenerSupport, hasListeners, instantiateInternalListener, isCollectStats, isEventFabricator, isSynthetic, isTranslateEvents, removeMapListener, removeMapListener, removeMapListener, setCollectStats, setTranslateEvents
containsKey, instantiateEntrySet, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, iterateKeys, size
clone, entrySet, equals, hashCode, keySet, values
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
finalize, getClass, notify, notifyAll, wait, wait, wait
as, async, async, clear
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListener
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
containsKey, containsValue, get, isEmpty, lock, lock, put, putAll, remove, size, unlock
aggregate, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getOrDefault, invokeAll, merge, merge, putIfAbsent, remove, replace, replace, replaceAll, replaceAll, replaceAll, replaceAll, stream, stream, stream, stream, stream, stream
protected String m_sName
protected CacheService m_service
public WrapperNamedCache(String sName)
sName
- the cache namepublic WrapperNamedCache(Map<K,V> map, String sName)
Note: it is assumed that while the WrapperNamedCache exists, there is no direct manipulation with the content of the wrapped map.
map
- the Map that will be wrapped by this WrapperNamedCachesName
- the cache namepublic WrapperNamedCache(Map<K,V> map, String sName, CacheService service)
Note: it is assumed that while the WrapperNamedCache exists, there is no direct manipulation with the content of the wrapped map.
map
- the Map that will be wrapped by this WrapperNamedCachesName
- the cache name (could be null if the map is a NamedCache)service
- the cache service this NamedCache is a part of (ignored if the map is a NamedCache)public String getCacheName()
getCacheName
in interface NamedCache<K,V>
public CacheService getCacheService()
getCacheService
in interface NamedCache<K,V>
public boolean isActive()
isActive
in interface NamedCache<K,V>
public void release()
Releasing a cache makes it no longer usable, but does not affect the cache itself. In other words, all other references to the cache will still be valid, and the cache data is not affected by releasing the reference. Any attempt to use this reference afterward will result in an exception.
Caches should be released by the same mechanism in which they were obtained. For example:
The purpose for releasing a cache is to allow the cache implementation to release the ClassLoader used to deserialize items in the cache. The cache implementation ensures that all references to that ClassLoader are released. This implies that objects in the cache that were loaded by that ClassLoader will be re-serialized to release their hold on that ClassLoader. The result is that the ClassLoader can be garbage-collected by Java in situations where the cache is operating in an application server and applications are dynamically loaded and unloaded.
release
in interface NamedCache<K,V>
CacheFactory.releaseCache(NamedCache)
, ConfigurableCacheFactory.releaseCache(NamedCache)
public void destroy()
Warning: This method is used to completely destroy the specified cache across the cluster. All references in the entire cluster to this cache will be invalidated, the cached data will be cleared, and all internal resources will be released.
Caches should be destroyed by the same mechanism in which they were obtained. For example:
destroy
in interface NamedCache<K,V>
CacheFactory.destroyCache(NamedCache)
, ConfigurableCacheFactory.destroyCache(NamedCache)
public void truncate()
Note: the removal of entries caused by this truncate operation will not be observable. This includes any registered listeners
, triggers
, or interceptors
. However, a CacheLifecycleEvent
is raised to notify subscribers of the execution of this operation.
truncate
in interface NamedCache<K,V>
public boolean isDestroyed()
isDestroyed
in interface NamedCache<K,V>
public boolean isReleased()
isReleased
in interface NamedCache<K,V>
public Map<K,V> getAll(Collection<? extends K> colKeys)
public V put(K oKey, V oValue, long cMillis)
Note: Though NamedCache interface extends CacheMap
, not all implementations currently support this functionality.
For example, if a cache is configured to be a replicated, optimistic or distributed cache then its backing map must be configured as a local cache. If a cache is configured to be a near cache then the front map must to be configured as a local cache and the back map must support this feature as well, typically by being a distributed cache backed by a local cache (as above.)
put
in interface CacheMap<K,V>
put
in interface NamedCache<K,V>
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified keycMillis
- the number of milliseconds until the cache entry will expire, also referred to as the entry's "time to live"; pass CacheMap.EXPIRY_DEFAULT
to use the cache's default time-to-live setting; pass CacheMap.EXPIRY_NEVER
to indicate that the cache entry should never expire; this milliseconds value is not a date/time value, such as is returned from System.currentTimeMillis()public Set<K> keySet(Filter filter)
Unlike the Map.keySet()
method, the set returned by this method may not be backed by the map, so changes to the set may not reflected in the map, and vice-versa.
Note: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.
public Set<Map.Entry<K,V>> entrySet(Filter filter)
Map.Entry
.
Unlike the Map.entrySet()
method, the set returned by this method may not be backed by the map, so changes to the set may not be reflected in the map, and vice-versa.
Note: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.
public Set<Map.Entry<K,V>> entrySet(Filter filter, Comparator comparator)
Map.Entry
. It is further guaranteed that its iterator will traverse the set in such a way that the entry values come up in ascending order, sorted by the specified Comparator or according to the natural ordering (see Comparable
).
Unlike the Map.entrySet()
method, the set returned by this method may not be backed by the map, so changes to the set may not be reflected in the map, and vice-versa.
Note: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the QueryMap interface using the Parallel Query feature. When using Coherence Standard Edition, the Parallel Query feature is not available, resulting in lower performance for most queries, and particularly when querying large data sets.
entrySet
in interface QueryMap<K,V>
filter
- the Filter object representing the criteria that the entries of this map should satisfycomparator
- the Comparator object which imposes an ordering on entries in the resulting set; or null if the entries' values natural ordering should be usedChainedComparator
public <T,E> void addIndex(ValueExtractor<? super T,? extends E> extractor, boolean fOrdered, Comparator<? super E> comparator)
The ordering maintained by this map (as determined by either the specified Comparator or the natural ordering of the indexed values) must be consistent with equals (see Comparable
or Comparator
for a precise definition of consistent with equals.)
This method is only intended as a hint to the cache implementation, and as such it may be ignored by the cache if indexes are not supported or if the desired index (or a similar index) already exists. It is expected that an application will call this method to suggest an index even if the index may already exist, just so that the application is certain that index has been suggested. For example in a distributed environment, each server will likely suggest the same set of indexes when it starts, and there is no downside to the application blindly requesting those indexes regardless of whether another server has already requested the same indexes.
Note: Indexes are a feature of Coherence Enterprise Edition and Coherence Grid Edition. This method will have no effect when using Coherence Standard Edition.
addIndex
in interface QueryMap<K,V>
T
- the type of the value to extract fromE
- the type of value that will be extractedextractor
- the ValueExtractor object that is used to extract an indexable Object from a value stored in the indexed Map. Must not be null.fOrdered
- true iff the contents of the indexed information should be ordered; false otherwisecomparator
- the Comparator object which imposes an ordering on entries in the indexed map; or null if the entries' values natural ordering should be usedReflectionExtractor
, ChainedComparator
public <T,E> void removeIndex(ValueExtractor<? super T,? extends E> extractor)
removeIndex
in interface QueryMap<K,V>
T
- the type of the value to extract fromE
- the type of value that will be extractedextractor
- the ValueExtractor object that is used to extract an indexable Object from a value stored in the Map.public <R> R invoke(K key, InvocableMap.EntryProcessor<K,V,R> agent)
invoke
in interface InvocableMap<K,V>
R
- the type of value returned by the EntryProcessorkey
- the key to process; it is not required to exist within the Mapagent
- the EntryProcessor to use to process the specified keypublic <R> Map<K,R> invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> agent)
invokeAll
in interface InvocableMap<K,V>
R
- the type of value returned by the EntryProcessorcollKeys
- the keys to process; these keys are not required to exist within the Mapagent
- the EntryProcessor to use to process the specified keyspublic <R> Map<K,R> invokeAll(Filter filter, InvocableMap.EntryProcessor<K,V,R> agent)
Unless specified otherwise, InvocableMap implementations will perform this operation in two steps: (1) use the filter to retrieve a matching entry set; (2) apply the agent to every filtered entry. This algorithm assumes that the agent's processing does not affect the result of the specified filter evaluation, since the filtering and processing could be performed in parallel on different threads. If this assumption does not hold, the processor logic has to be idempotent, or at least re-evaluate the filter. This could be easily accomplished by wrapping the processor with the ConditionalProcessor
.
invokeAll
in interface InvocableMap<K,V>
R
- the type of value returned by the EntryProcessorfilter
- a Filter that results in the set of keys to be processedagent
- the EntryProcessor to use to process the specified keyspublic <R> R aggregate(Collection<? extends K> collKeys, InvocableMap.EntryAggregator<? super K,? super V,R> agent)
aggregate
in interface InvocableMap<K,V>
R
- the type of value returned by the EntryAggregatorcollKeys
- the Collection of keys that specify the entries within this Map to aggregate acrossagent
- the EntryAggregator that is used to aggregate across the specified entries of this Mappublic <R> R aggregate(Filter filter, InvocableMap.EntryAggregator<? super K,? super V,R> agent)
aggregate
in interface InvocableMap<K,V>
R
- the type of value returned by the EntryAggregatorfilter
- the Filter that is used to select entries within this Map to aggregate acrossagent
- the EntryAggregator that is used to aggregate across the selected entries of this Map