|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.net.cache.CachingMap
com.tangosol.net.cache.NearCache
public class NearCache
A "near cache" is a CachingMap whose front map is a size-limited and/or auto-expiring local cache, and whose back map is a distributed cache. (A CachingMap is a map that has a "front" map and a "back" map; the front map is assumed to be low latency but incomplete, and the back map is assumed to be complete but high latency.)
Invalidation strategies
Nested Class Summary | |
---|---|
protected class |
NearCache.BackServiceListener MemberListener for the back cache's service. |
Nested classes/interfaces inherited from class com.tangosol.net.cache.CachingMap |
---|
CachingMap.BackMapListener, CachingMap.FrontMapListener |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry |
Nested classes/interfaces inherited from interface com.tangosol.util.QueryMap |
---|
QueryMap.Entry |
Nested classes/interfaces inherited from interface com.tangosol.util.InvocableMap |
---|
InvocableMap.Entry, InvocableMap.EntryAggregator, InvocableMap.EntryProcessor, InvocableMap.ParallelAwareAggregator |
Field Summary | |
---|---|
protected MemberListener |
m_listenerBackService The back cache service MemberListener. |
protected CacheService |
m_service The back cache service. |
protected java.lang.String |
m_sName The cache name. |
Fields inherited from class com.tangosol.net.cache.CachingMap |
---|
LISTEN_ALL, LISTEN_AUTO, LISTEN_LOGICAL, LISTEN_NONE, LISTEN_PRESENT, m_nStrategyCurrent, m_nStrategyTarget |
Fields inherited from interface com.tangosol.net.cache.CacheMap |
---|
EXPIRY_DEFAULT, EXPIRY_NEVER |
Fields inherited from interface com.tangosol.util.ConcurrentMap |
---|
LOCK_ALL |
Constructor Summary | |
---|---|
NearCache(java.util.Map mapFront, NamedCache mapBack) Construct a NearCache, using a mapBack NamedCache as the complete (back) storage and mapFront Map as a near (front) storage using the CachingMap.LISTEN_AUTO invalidation strategy. |
|
NearCache(java.util.Map mapFront, NamedCache mapBack, int nStrategy) Construct a NearCache, using a mapBack NamedCache as the complete (back) storage and mapFront Map as a near (front) storage. |
Method Summary | |
---|---|
void |
addIndex(ValueExtractor extractor, boolean fOrdered, java.util.Comparator comparator) Add an index to this QueryMap. |
void |
addMapListener(MapListener listener) Add a standard map listener. |
void |
addMapListener(MapListener listener, Filter filter, boolean fLite) Add a map listener that receives events based on a filter evaluation. |
void |
addMapListener(MapListener listener, java.lang.Object oKey, boolean fLite) Add a map listener for a specific key. |
java.lang.Object |
aggregate(java.util.Collection collKeys, InvocableMap.EntryAggregator agent) Perform an aggregating operation against the entries specified by the passed keys. |
java.lang.Object |
aggregate(Filter filter, InvocableMap.EntryAggregator 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. |
java.util.Set |
entrySet(Filter filter) Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. |
java.util.Set |
entrySet(Filter filter, java.util.Comparator comparator) Return a set view of the entries contained in this map that satisfy the criteria expressed by the filter. |
NamedCache |
getBackCache() Obtain the NamedCache object that sits behind this NearCache. |
java.lang.String |
getCacheName() Return the cache name. |
CacheService |
getCacheService() Return the CacheService that this NamedCache is a part of. |
java.lang.ClassLoader |
getContextClassLoader() Retrieve the context ClassLoader for this object. |
java.lang.String |
getRegistrationContext() Obtain the context (tier) used to register a CacheMBean for this cache. |
java.lang.Object |
invoke(java.lang.Object oKey, InvocableMap.EntryProcessor agent) Invoke the passed EntryProcessor against the Entry specified by the passed key, returning the result of the invocation. |
java.util.Map |
invokeAll(java.util.Collection collKeys, InvocableMap.EntryProcessor agent) Invoke the passed EntryProcessor against the entries specified by the passed keys, returning the result of the invocation for each. |
java.util.Map |
invokeAll(Filter filter, InvocableMap.EntryProcessor 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. |
java.util.Set |
keySet(Filter filter) Return a set view of the keys contained in this map for entries that satisfy the criteria expressed by the filter. |
boolean |
lock(java.lang.Object oKey) Attempt to lock the specified item and return immediately. |
boolean |
lock(java.lang.Object oKey, long lMillis) Attempt to lock the specified item within the specified period of time. |
java.lang.Object |
put(java.lang.Object oKey, java.lang.Object oValue, long cMillis) Associates the specified value with the specified key in this cache and allows to specify an expiry for the cache entry. |
protected MemberListener |
registerBackServiceListener() Instantiate and register a MemberListener with the back cache service. |
void |
release() Release the CachingMap. |
protected void |
release(boolean fDestroy) Release this cache, optionally destroying it. |
void |
removeIndex(ValueExtractor extractor) Remove an index from this QueryMap. |
void |
removeMapListener(MapListener listener) Remove a standard map listener. |
void |
removeMapListener(MapListener listener, Filter filter) Remove a map listener that previously signed up for events based on a filter evaluation. |
void |
removeMapListener(MapListener listener, java.lang.Object oKey) Remove a map listener that previously signed up for events about a specific key. |
void |
setContextClassLoader(java.lang.ClassLoader loader) Specify the context ClassLoader for this object. |
void |
setRegistrationContext(java.lang.String sCtx) Set the context (tier) used to register a CacheMBean for this cache. |
boolean |
unlock(java.lang.Object oKey) Unlock the specified item. |
protected void |
unregisterBackServiceListener() Unregister back cache service member listener. |
Methods inherited from interface com.tangosol.net.cache.CacheMap |
---|
getAll, put |
Methods inherited from interface java.util.Map |
---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, values |
Methods inherited from interface com.tangosol.util.ConcurrentMap |
---|
clear, containsKey, containsValue, get, isEmpty, put, putAll, remove, size |
Field Detail |
---|
protected final java.lang.String m_sName
protected final CacheService m_service
protected final MemberListener m_listenerBackService
Constructor Detail |
---|
public NearCache(java.util.Map mapFront, NamedCache mapBack)
CachingMap.LISTEN_AUTO
invalidation strategy.
mapFront
- Map to put in front of the back cachemapBack
- NamedCache to put behind the front cachepublic NearCache(java.util.Map mapFront, NamedCache mapBack, int nStrategy)
mapFront
- Map to put in front of the back cachemapBack
- NamedCache to put behind the front cachenStrategy
- specifies the strategy used for the front map invalidation; valid values are:LISTEN_NONE
, LISTEN_PRESENT
, LISTEN_ALL
, LISTEN_AUTO
Method Detail |
---|
public NamedCache getBackCache()
java.lang.IllegalStateException
- if this NamedCache has been releasedpublic java.lang.String getRegistrationContext()
public void setRegistrationContext(java.lang.String sCtx)
sCtx
- the corresponding context stringpublic java.lang.String getCacheName()
getCacheName
in interface NamedCache
public CacheService getCacheService()
getCacheService
in interface NamedCache
public boolean isActive()
isActive
in interface NamedCache
public void release()
release
in interface NamedCache
release
in class CachingMap
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
CacheFactory.destroyCache(NamedCache)
, ConfigurableCacheFactory.destroyCache(NamedCache)
public void addMapListener(MapListener listener)
addMapListener
in interface ObservableMap
listener
- the MapEvent listener to addpublic void removeMapListener(MapListener listener)
removeMapListener
in interface ObservableMap
listener
- the MapEvent listener to removepublic void addMapListener(MapListener listener, java.lang.Object oKey, boolean fLite)
addMapListener
in interface ObservableMap
listener
- the listener to addoKey
- the key that identifies the entry for which to raise eventsfLite
- true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values in order to allow optimizationspublic void removeMapListener(MapListener listener, java.lang.Object oKey)
removeMapListener
in interface ObservableMap
listener
- the listener to removeoKey
- the key that identifies the entry for which to raise eventspublic void addMapListener(MapListener listener, Filter filter, boolean fLite)
addMapListener
in interface ObservableMap
listener
- the listener to addfilter
- a filter that will be passed MapEvent objects to select from; a MapEvent will be delivered to the listener only if the filter evaluates to true for that MapEvent; null is equivalent to a filter that always returns truefLite
- true to indicate that the MapEvent objects do not have to include the OldValue and NewValue property values in order to allow optimizationspublic void removeMapListener(MapListener listener, Filter filter)
removeMapListener
in interface ObservableMap
listener
- the listener to removefilter
- a filter used to evaluate eventspublic java.lang.Object put(java.lang.Object oKey, java.lang.Object oValue, long cMillis)
put
in interface CacheMap
put
in interface NamedCache
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 expirejava.lang.UnsupportedOperationException
- if the requested expiry is a positive value and either the front map or the back map implementations do not support the expiration functionalityCacheMap.put(Object oKey, Object oValue, long cMillis)
public boolean lock(java.lang.Object oKey)
lock
in interface ConcurrentMap
oKey
- key being lockedpublic boolean lock(java.lang.Object oKey, long lMillis)
lock
in interface ConcurrentMap
oKey
- key being lockedlMillis
- the number of milliseconds to continue trying to obtain a lock; pass zero to return immediately; pass -1 to block the calling thread until the lock could be obtainedpublic boolean unlock(java.lang.Object oKey)
unlock
in interface ConcurrentMap
oKey
- key being unlockedpublic java.util.Set 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.
The operation always executes against the back cache.
keySet
in interface QueryMap
filter
- the Filter object representing the criteria that the entries of this map should satisfypublic java.util.Set 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.
The operation always executes against the back cache.
entrySet
in interface QueryMap
filter
- the Filter object representing the criteria that the entries of this map should satisfypublic java.util.Set entrySet(Filter filter, java.util.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.
The operation always executes against the back cache.
entrySet
in interface QueryMap
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 void addIndex(ValueExtractor extractor, boolean fOrdered, java.util.Comparator comparator)
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.
The operation always executes against the back cache.
addIndex
in interface QueryMap
extractor
- 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 void removeIndex(ValueExtractor extractor)
The operation always executes against the back cache.
removeIndex
in interface QueryMap
extractor
- the ValueExtractor object that is used to extract an indexable Object from a value stored in the Map.public java.lang.Object invoke(java.lang.Object oKey, InvocableMap.EntryProcessor agent)
The operation always executes against the back cache.
invoke
in interface InvocableMap
oKey
- the key to process; it is not required to exist within the Mapagent
- the EntryProcessor to use to process the specified keypublic java.util.Map invokeAll(java.util.Collection collKeys, InvocableMap.EntryProcessor agent)
The operation always executes against the back cache.
invokeAll
in interface InvocableMap
collKeys
- the keys to process; these keys are not required to exist within the Mapagent
- the EntryProcessor to use to process the specified keyspublic java.util.Map invokeAll(Filter filter, InvocableMap.EntryProcessor 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
.
The operation always executes against the back cache.
invokeAll
in interface InvocableMap
filter
- a Filter that results in the set of keys to be processedagent
- the EntryProcessor to use to process the specified keyspublic java.lang.Object aggregate(java.util.Collection collKeys, InvocableMap.EntryAggregator agent)
The operation always executes against the back cache.
aggregate
in interface InvocableMap
collKeys
- 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 java.lang.Object aggregate(Filter filter, InvocableMap.EntryAggregator agent)
The operation always executes against the back cache.
aggregate
in interface InvocableMap
filter
- 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 Mapprotected void release(boolean fDestroy)
fDestroy
- true to destroy the cache as wellprotected MemberListener registerBackServiceListener()
The primary goal of that listener is invalidation of the front map in case of the service [automatic] restart.
protected void unregisterBackServiceListener()
public java.lang.ClassLoader getContextClassLoader()
getContextClassLoader
in interface ClassLoaderAware
Thread.getContextClassLoader()
public void setContextClassLoader(java.lang.ClassLoader loader)
setContextClassLoader
in interface ClassLoaderAware
loader
- the context ClassLoader for this object
|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |