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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn immutable option for requesting and configuringNamedMaps.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.voidclear()Removes all mappings from this map.default voidforEach(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 StringgetName()Obtain the name of this NamedCollection.default CacheServiceReturn the Service that this NamedCollection is a part of.booleanisActive()Returnstrueif this map is not released or destroyed.default booleanisReady()Returns whether thisNamedMapis ready to be used.default voidtruncate()Removes all mappings from this map.default MapViewBuilder<K, V> view()Construct aviewof thisNamedMap.Methods inherited from interface com.tangosol.util.ConcurrentMap
containsKey, containsValue, get, isEmpty, lock, lock, put, putAll, remove, size, unlockMethods 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, streamMethods inherited from interface com.tangosol.net.NamedCollection
destroy, isDestroyedMethods inherited from interface com.tangosol.util.ObservableMap
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListenerMethods inherited from interface com.tangosol.util.QueryMap
addIndex, addIndex, entrySet, entrySet, forEach, forEach, keySet, removeIndex, values, valuesMethods inherited from interface com.tangosol.net.Releasable
close, isReleased, release
-
Method Details
-
getName
Description copied from interface:NamedCollectionObtain the name of this NamedCollection.- Specified by:
getNamein interfaceNamedCollection- Returns:
- the name of this NamedCollection
-
getService
Description copied from interface:NamedCollectionReturn the Service that this NamedCollection is a part of.- Specified by:
getServicein 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, aCacheLifecycleEventis 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 aviewof thisNamedMap.- Returns:
- a local
viewfor thisNamedMap - Since:
- 12.2.1.4
- See Also:
-
isReady
default boolean isReady()Returns whether thisNamedMapis ready to be used. An example of when this method would returnfalsewould be where a partitioned cache service that owns this cache has no storage-enabled members.- Returns:
- return
trueif theNamedMapmay be used otherwise returnsfalse. - Since:
- 14.1.1.2206.5
-
isActive
boolean isActive()Returnstrueif this map is not released or destroyed. In other words, callingisActive()is equivalent to calling!cache.isReleased() && !cache.isDestroyed().- Specified by:
isActivein interfaceReleasable- Returns:
trueif the cache is active, otherwisefalse
-