CoherenceTM v3.4
Copyright© 2000-2008 by Oracle Corporation

com.tangosol.net
Interface NamedCache

All Superinterfaces:
CacheMap, ConcurrentMap, InvocableMap, java.util.Map, ObservableMap, QueryMap
All Known Implementing Classes:
BundlingNamedCache, ContinuousQueryCache, ConverterCollections.ConverterNamedCache, NearCache, ReadonlyNamedCache, VersionedNearCache, WrapperNamedCache

public interface NamedCache
extends ObservableMap, CacheMap, ConcurrentMap, QueryMap, InvocableMap

A NamedCache is a Map that holds resources shared among members of a cluster. These resources are expected to be managed in memory, and are typically composed of data that are also stored persistently in a database, or data that have been assembled or calculated at some significant cost, thus these resources are referred to as cached.

Note: When using the Coherence Enterprise Edition or Grid Edition, the Partitioned Cache implements the InvocableMap interface by partitioning and localizing the invocations, resulting in extremely high throughput and low latency. When using Coherence Standard Edition, the InvocableMap processes the invocations on the originating node, typically resulting in higher network, memory and CPU utilization, which translates to lower performance, and particularly when processing large data sets.

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.

Since:
Coherence 1.1.2
Author:
gg 2002.03.27

Nested Class Summary
 
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
 
Fields inherited from interface com.tangosol.net.cache.CacheMap
EXPIRY_DEFAULT, EXPIRY_NEVER
 
Fields inherited from interface com.tangosol.util.ConcurrentMap
LOCK_ALL
 
Method Summary
 void destroy()
          Release and destroy this instance of NamedCache.
 java.lang.String getCacheName()
          Return the cache name.
 CacheService getCacheService()
          Return the CacheService that this NamedCache is a part of.
 boolean isActive()
          Specifies whether or not the NamedCache is active.
 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.
 void release()
          Release local resources associated with this instance of NamedCache.
 
Methods inherited from interface com.tangosol.net.cache.CacheMap
getAll, put
 
Methods inherited from interface com.tangosol.util.ConcurrentMap
clear, containsKey, containsValue, get, isEmpty, lock, lock, put, putAll, remove, size, unlock
 
Methods inherited from interface com.tangosol.util.QueryMap
addIndex, entrySet, entrySet, keySet, removeIndex
 
Methods inherited from interface com.tangosol.util.InvocableMap
aggregate, aggregate, invoke, invokeAll, invokeAll
 

Method Detail

getCacheName

java.lang.String getCacheName()
Return the cache name.

Returns:
the cache name

getCacheService

CacheService getCacheService()
Return the CacheService that this NamedCache is a part of.

Returns:
the CacheService

isActive

boolean isActive()
Specifies whether or not the NamedCache is active.

Returns:
true if the NamedCache is active; false otherwise

release

void release()
Release local resources associated with this instance of NamedCache.

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 afterword will result in an exception.

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.

See Also:
CacheService.releaseCache(NamedCache)

destroy

void destroy()
Release and destroy this instance of NamedCache.

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 resources will be released.

See Also:
CacheService.destroyCache(NamedCache)

put

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.

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.)

Specified by:
put in interface CacheMap
Parameters:
oKey - key with which the specified value is to be associated
oValue - value to be associated with the specified key
cMillis - 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()
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values
Throws:
java.lang.UnsupportedOperationException - if the requested expiry is a positive value and the implementation does not support expiry of cache entries
Since:
Coherence 2.3

CoherenceTM v3.4
Copyright© 2000-2008 by Oracle Corporation