K - the type of the Map entry keysV - the type of the Map entry valuespublic interface CacheMap<K,V> extends ObservableMap<K,V>
| Modifier and Type | Field and Description |
|---|---|
static 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. |
static 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. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
Map<K,V> |
getAll(Collection<? extends K> colKeys)
Get all the specified keys, if they are in the cache.
|
V |
put(K key, V value)
Associates the specified value with the specified key in this cache.
|
V |
put(K key, V value, long cMillis)
Associates the specified value with the specified key in this cache.
|
addMapListener, addMapListener, addMapListener, removeMapListener, removeMapListener, removeMapListenerclear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesstatic final long EXPIRY_DEFAULT
put method to indicate that the cache's default expiry should be used.static final long EXPIRY_NEVER
put method to indicate that the cache entry should never expire.Map<K,V> getAll(Collection<? extends K> colKeys)
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;
colKeys - a collection of keys that may be in the named cacheV put(K key, V value)
Invoking this method is equivalent to the following call:
put(oKey, oValue, EXPIRY_DEFAULT);
put in interface Map<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keyV put(K key, V value, long cMillis)
put(Object oKey, Object oValue) method allows the caller to specify an expiry (or "time to live") for the cache entry.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 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()UnsupportedOperationException - if the requested expiry is a positive value and the implementation does not support expiry of cache entriesdefault void forEach(Collection<? extends K> collKeys, BiConsumer<? super K,? super V> action)
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.
collKeys - the keys to process; these keys are not required to exist within the Mapaction - the action to be performed for each entry