Interface CacheMap<K,V>

Type Parameters:
K - the type of the Map entry keys
V - the type of the Map entry values
All Superinterfaces:
Map<K,V>, ObservableMap<K,V>
All Known Subinterfaces:
ConfigurableCacheMap, NamedCache<K,V>
All Known Implementing Classes:
BundlingNamedCache, CaffeineCache, ContinuousQueryCache, ConverterCollections.ConverterCacheMap, ConverterCollections.ConverterNamedCache, LocalCache, NearCache, ObservableSplittingBackingCache, ObservableSplittingBackingMap, OverflowMap, ReadonlyNamedCache, ReadWriteBackingMap, ReadWriteSplittingBackingMap, SerializationCache, VersionedBackingMap, VersionedNearCache, WrapperNamedCache

public interface CacheMap<K,V> extends ObservableMap<K,V>
A CacheMap is a Map that supports caching.
Since:
Coherence 2.3
Author:
gg 2004.01.05
  • Field Details

    • EXPIRY_DEFAULT

      static final long EXPIRY_DEFAULT
      A special time-to-live value that can be passed to the extended put method to indicate that the cache's default expiry should be used.
      See Also:
    • EXPIRY_NEVER

      static final long EXPIRY_NEVER
      A special time-to-live value that can be passed to the extended put method to indicate that the cache entry should never expire.
      See Also:
  • Method Details

    • getAll

      Map<K,V> getAll(Collection<? extends K> colKeys)
      Get all the specified keys, if they are in the cache. For each key that is in the cache, 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 cache, which may imply (for caches 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 cache
      Returns:
      a Map of keys to values for the specified keys passed in colKeys
      Since:
      Coherence 2.5
    • put

      V put(K key, V value)
      Associates the specified value with the specified key in this cache. If the cache previously contained a mapping for this key, the old value is replaced.

      Invoking this method is equivalent to the following call:

           put(oKey, oValue, EXPIRY_DEFAULT);
       
      Specified by:
      put in interface Map<K,V>
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      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
    • put

      V put(K key, V value, long cMillis)
      Associates the specified value with the specified key in this cache. If the cache previously contained a mapping for this key, the old value is replaced. This variation of the put(Object oKey, Object oValue) method allows the caller to specify an expiry (or "time to live") for the cache entry.
      Parameters:
      key - key with which the specified value is to be associated
      value - 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 EXPIRY_DEFAULT to use the cache's default time-to-live setting; pass 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:
      UnsupportedOperationException - if the requested expiry is a positive value and the implementation does not support expiry of cache entries
    • 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