Interface NamedMap<K,V>

Type Parameters:
K - the type of the map entry keys
V - 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

public interface NamedMap<K,V> extends NamedCollection, ObservableMap<K,V>, ConcurrentMap<K,V>, QueryMap<K,V>, InvocableMap<K,V>
A Map-based data-structure that manages entries across one or more processes. Entries are typically managed in memory, and are often comprised of data that is also stored persistently, on disk.
Since:
20.06
Author:
Aleks Seovic 2020.06.06
  • Method Details

    • getName

      default String getName()
      Description copied from interface: NamedCollection
      Obtain the name of this NamedCollection.
      Specified by:
      getName in interface NamedCollection
      Returns:
      the name of this NamedCollection
    • getService

      default CacheService getService()
      Description copied from interface: NamedCollection
      Return the Service that this NamedCollection is a part of.
      Specified by:
      getService in interface NamedCollection
      Returns:
      the Service
    • getAll

      Map<K,V> getAll(Collection<? extends K> colKeys)
      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. Either truncate() or NamedCollection.destroy() operations may be suitable alternatives.

      Specified by:
      clear in interface ConcurrentMap<K,V>
      Specified by:
      clear in interface Map<K,V>
    • 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, or interceptors. However, a CacheLifecycleEvent is raised to notify subscribers of the execution of this operation.

      Throws:
      UnsupportedOperationException - if the server does not support the truncate operation
    • forEach

      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.

      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>), or Map.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 Map
      action - the action to be performed for each entry
      Since:
      12.2.1
    • async

      default AsyncNamedMap<K,V> async(AsyncNamedMap.Option... options)
      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

      default MapViewBuilder<K,V> view()
      Construct a view of this NamedMap.
      Returns:
      a local view for this NamedMap
      Since:
      12.2.1.4
      See Also:
    • isReady

      default boolean isReady()
      Returns whether this NamedMap is ready to be used.

      An example of when this method would return false would be where a partitioned cache service that owns this cache has no storage-enabled members.
      Returns:
      return true if the NamedMap may be used otherwise returns false.
      Since:
      14.1.1.2206.5
    • isActive

      boolean isActive()
      Returns true if this map is not released or destroyed. In other words, calling isActive() is equivalent to calling !cache.isReleased() && !cache.isDestroyed().
      Specified by:
      isActive in interface Releasable
      Returns:
      true if the cache is active, otherwise false