K
- the type of the cache entry keysV
- the type of the cache entry valuespublic interface NamedCache<K,V> extends NamedCollection, ObservableMap<K,V>, CacheMap<K,V>, ConcurrentMap<K,V>, QueryMap<K,V>, InvocableMap<K,V>
Modifier and Type | Interface and Description |
---|---|
static interface |
NamedCache.Option
An immutable option for requesting and configuring
NamedCache s. |
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>
EXPIRY_DEFAULT, EXPIRY_NEVER
LOCK_ALL
Modifier and Type | Method and Description |
---|---|
default <C extends NamedCache<K,V>> |
as(Class<C> clzNamedCache)
Request a specific type of reference to a
NamedCache that this
NamedCache may additionally implement or support. |
default AsyncNamedCache<K,V> |
async()
Return an asynchronous wrapper for this NamedCache.
|
default AsyncNamedCache<K,V> |
async(AsyncNamedCache.Option... options)
Return an asynchronous wrapper for this NamedCache.
|
void |
clear()
Removes all mappings from this map.
|
String |
getCacheName()
Return the cache name.
|
CacheService |
getCacheService()
Return the CacheService that this NamedCache is a part of.
|
default String |
getName()
Obtain the name of this NamedCollection.
|
default CacheService |
getService()
Return the Service that this NamedCollection is a part of.
|
default boolean |
isDestroyed()
Specifies whether or not the NamedCache has been destroyed.
|
default boolean |
isReleased()
Specifies whether or not the NamedCache has been released.
|
V |
put(K key,
V value,
long cMillis)
Associates the specified value with the specified key in this cache and
allows to specify an expiry for the cache entry.
|
default void |
truncate()
Removes all mappings from this map.
|
default ViewBuilder<K,V> |
view()
Construct a
view of this NamedCache . |
destroy
close, isActive, release
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
addIndex, entrySet, entrySet, forEach, forEach, keySet, removeIndex, values, values
aggregate, aggregate, aggregate, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getOrDefault, invoke, invokeAll, invokeAll, invokeAll, merge, merge, putIfAbsent, remove, replace, replace, replaceAll, replaceAll, replaceAll, replaceAll, stream, stream, stream, stream, stream, stream
String getCacheName()
CacheService getCacheService()
default String getName()
NamedCollection
getName
in interface NamedCollection
default CacheService getService()
NamedCollection
getService
in interface NamedCollection
V put(K key, V value, 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>
key
- key with which the specified value is to be associatedvalue
- 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()UnsupportedOperationException
- if the requested expiry is a
positive value and the implementation does not support expiry
of cache entriesvoid clear()
Note: invoking the clear()
operation against a distributed cache
can be both a memory and CPU intensive task and therefore is generally
not recommended. Either truncate()
or NamedCollection.destroy()
operations
may be suitable alternatives.
default 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.
UnsupportedOperationException
- if the server does not support the truncate operationdefault <C extends NamedCache<K,V>> C as(Class<C> clzNamedCache)
NamedCache
that this
NamedCache
may additionally implement or support.C
- the type of NamedCache
clzNamedCache
- the class of NamedCache
NamedCache
of the requested typeUnsupportedOperationException
- when this NamedCache
doesn't support or implement
the requested classdefault AsyncNamedCache<K,V> async()
By default, the order of execution of asynchronous operation invoked on
the returned AsyncNamedCache will be preserved by ensuring that all
operations invoked from the same client thread are executed on the server
sequentially, using the same unit-of-order
. This tends to provide best performance for fast,
non-blocking operations.
However, when invoking CPU-intensive or blocking operations, such as
read- or write-through operations that access remote database or web
service, for example, it may be very beneficial to allow the server to
parallelize execution by passing AsyncNamedCache.OrderBy.none()
configuration option to the async(AsyncNamedCache.Option...)
method. Note, that in that case there are no guarantees for the order
of execution.
default AsyncNamedCache<K,V> async(AsyncNamedCache.Option... options)
By default, the order of execution of asynchronous operation invoked on
the returned AsyncNamedCache will be preserved by ensuring that all
operations invoked from the same client thread are executed on the server
sequentially, using the same unit-of-order
. This tends to provide the best performance for fast,
non-blocking operations.
However, when invoking CPU-intensive or blocking operations, such as
read- or write-through operations that access remote database or web
service, for example, it may be very beneficial to allow the server to
parallelize execution by passing AsyncNamedCache.OrderBy.none()
configuration option to this method. Note, that in that case there are
no guarantees for the order of execution.
options
- the configuration optionsdefault boolean isDestroyed()
default boolean isReleased()
default ViewBuilder<K,V> view()
view
of this NamedCache
.view
for this NamedCache
ViewBuilder