Interface NamedMap<K,V>
- Type Parameters:
K
- the type of the map entry keysV
- the type of the map entry values
- All Superinterfaces:
AutoCloseable
,ConcurrentMap<K,
,V> InvocableMap<K,
,V> Map<K,
,V> NamedCollection
,ObservableMap<K,
,V> QueryMap<K,
,V> Releasable
- All Known Subinterfaces:
NamedCache<K,
V>
- All Known Implementing Classes:
BundlingNamedCache
,ContinuousQueryCache
,ConverterCollections.ConverterNamedCache
,NearCache
,ReadonlyNamedCache
,VersionedNearCache
,WrapperNamedCache
- Since:
- 20.06
- Author:
- Aleks Seovic 2020.06.06
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
An immutable option for requesting and configuringNamedMap
s.Nested classes/interfaces inherited from interface com.tangosol.util.InvocableMap
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> Nested classes/interfaces inherited from interface com.tangosol.util.QueryMap
QueryMap.Entry<K,
V> -
Field Summary
Fields inherited from interface com.tangosol.util.ConcurrentMap
LOCK_ALL
-
Method Summary
Modifier and TypeMethodDescriptiondefault AsyncNamedMap
<K, V> async
(AsyncNamedMap.Option... options) Return an asynchronous wrapper for this NamedMap.void
clear()
Removes all mappings from this map.default void
forEach
(Collection<? extends K> collKeys, BiConsumer<? super K, ? super V> action) Perform the given action for each entry selected by the specified key set until all entries have been processed or the action throws an exception.getAll
(Collection<? extends K> colKeys) Get all the specified keys, if they are in the map.default String
getName()
Obtain the name of this NamedCollection.default CacheService
Return the Service that this NamedCollection is a part of.boolean
isActive()
Returnstrue
if this map is not released or destroyed.default boolean
isReady()
Returns whether thisNamedMap
is ready to be used.default void
truncate()
Removes all mappings from this map.default MapViewBuilder
<K, V> view()
Construct aview
of thisNamedMap
.Methods inherited from interface com.tangosol.util.ConcurrentMap
containsKey, containsValue, get, isEmpty, lock, lock, put, putAll, remove, size, unlock
Methods inherited from interface com.tangosol.util.InvocableMap
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
Methods inherited from interface com.tangosol.net.NamedCollection
destroy, isDestroyed
Methods inherited from interface com.tangosol.util.ObservableMap
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListener
Methods inherited from interface com.tangosol.util.QueryMap
addIndex, addIndex, entrySet, entrySet, forEach, forEach, keySet, removeIndex, values, values
Methods inherited from interface com.tangosol.net.Releasable
close, isReleased, release
-
Method Details
-
getName
Description copied from interface:NamedCollection
Obtain the name of this NamedCollection.- Specified by:
getName
in interfaceNamedCollection
- Returns:
- the name of this NamedCollection
-
getService
Description copied from interface:NamedCollection
Return the Service that this NamedCollection is a part of.- Specified by:
getService
in interfaceNamedCollection
- Returns:
- the Service
-
getAll
Get all the specified keys, if they are in the map. For each key that is in the map, that key and its corresponding value will be placed in the map that is returned by this method. The absence of a key in the returned map indicates that it was not in the map, which may imply (for maps that can load behind the scenes) that the requested data could not be loaded.The result of this method is defined to be semantically the same as the following implementation, without regards to threading issues:
Map map = new AnyMap(); // could be a HashMap (but does not have to) for (Iterator iter = colKeys.iterator(); iter.hasNext(); ) { Object oKey = iter.next(); Object oVal = get(oKey); if (oVal != null || containsKey(oKey)) { map.put(oKey, oVal); } } return map;
- Parameters:
colKeys
- a collection of keys that may be in the named map- Returns:
- a Map of keys to values for the specified keys passed in colKeys
-
clear
void clear()Removes all mappings from this map.Note: invoking the
clear()
operation against a distributed map can be both a memory and CPU intensive task and therefore is generally not recommended. Eithertruncate()
orNamedCollection.destroy()
operations may be suitable alternatives. -
truncate
default void truncate()Removes all mappings from this map.Note: the removal of entries caused by this truncate operation will not be observable. This includes any registered
listeners
,triggers
, orinterceptors
. However, aCacheLifecycleEvent
is raised to notify subscribers of the execution of this operation.- Throws:
UnsupportedOperationException
- if the server does not support the truncate operation
-
forEach
Perform the given action for each entry selected by the specified key set until all entries have been processed or the action throws an exception.Exceptions thrown by the action are relayed to the caller.
The implementation processes each entry on the client and should only be used for read-only client-side operations (such as adding map entries to a UI widget, for example).
Any entry mutation caused by the specified action will not be propagated to the server when this method is called on a distributed map, so it should be avoided. The mutating operations on a subset of entries should be implemented using one of
InvocableMap.invokeAll(com.tangosol.util.InvocableMap.EntryProcessor<K, V, R>)
,Map.replaceAll(java.util.function.BiFunction<? super K, ? super V, ? extends V>)
,Map.compute(K, java.util.function.BiFunction<? super K, ? super V, ? extends V>)
, orMap.merge(K, V, java.util.function.BiFunction<? super V, ? super V, ? extends V>)
methods instead.- Parameters:
collKeys
- the keys to process; these keys are not required to exist within the Mapaction
- the action to be performed for each entry- Since:
- 12.2.1
-
async
Return an asynchronous wrapper for this NamedMap.By default, the order of execution of asynchronous operation invoked on the returned AsyncNamedMap 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
AsyncNamedMap.OrderBy.none()
configuration option to this method. Note, that in that case there are no guarantees for the order of execution.- Parameters:
options
- the configuration options- Returns:
- asynchronous wrapper for this NamedMap
-
view
Construct aview
of thisNamedMap
.- Returns:
- a local
view
for thisNamedMap
- Since:
- 12.2.1.4
- See Also:
-
isReady
default boolean isReady()Returns whether thisNamedMap
is ready to be used. An example of when this method would returnfalse
would be where a partitioned cache service that owns this cache has no storage-enabled members.- Returns:
- return
true
if theNamedMap
may be used otherwise returnsfalse
. - Since:
- 14.1.1.2206.5
-
isActive
boolean isActive()Returnstrue
if this map is not released or destroyed. In other words, callingisActive()
is equivalent to calling!cache.isReleased() && !cache.isDestroyed()
.- Specified by:
isActive
in interfaceReleasable
- Returns:
true
if the cache is active, otherwisefalse
-