Package org.infinispan.multimap.impl
Class EmbeddedMultimapCache<K,V>
java.lang.Object
org.infinispan.multimap.impl.EmbeddedMultimapCache<K,V>
- All Implemented Interfaces:
BasicMultimapCache<K,,V> MultimapCache<K,V>
Embedded implementation of
MultimapCache
Transactions
EmbeddedMultimapCache supports implicit transactions without blocking. The following methods block when they are called in a explicit transaction context. This limitation could be improved in the following versions if technically possible : More about transactions in : the Infinispan Documentation.Duplicates
MultimapCache can optionally support duplicate values on keys. {@link <pre> multimapCache.put("k", "v1").join(); multimapCache.put("k", "v2").join(); multimapCache.put("k", "v2").join(); multimapCache.put("k", "v2").join(); multimapCache.get("k").thenAccept(values -> System.out.println(values.size())); // prints the value 4. "k" -> ["v1", "v2", "v2", "v2"]- Since:
- 9.2
- Author:
- Katia Aresti, karesti@redhat.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncontainsEntry(K key, V value) ReturnsBoolean.TRUEif this multimap cache contains the key-value pair.containsKey(K key) ReturnsBoolean.TRUEif this multimap cache contains the key.containsValue(V value) Asynchronous method that returnsBoolean.TRUEif this multimap cache contains the value at any key.Returns a view collection of the values associated with key in this multimap cache, if any.getCache()Retrieves a CacheEntry corresponding to a specific key in this multimap cache.Puts a key-value pair in this multimap cache.Asynchronous method.Removes all the key-value pairs associated with the key from this multimap cache, if such exists.Removes a key-value pair from this multimap cache, if such exists.size()Returns the number of key-value pairs in this multimap cache.booleanMultimap can support duplicates on the same key k → ['a', 'a', 'b'] or not k → ['a', 'b'] depending on configuration.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.multimap.api.embedded.MultimapCache
remove
-
Constructor Details
-
EmbeddedMultimapCache
-
-
Method Details
-
put
Description copied from interface:BasicMultimapCachePuts a key-value pair in this multimap cache.- If this multimap cache supports duplicates, the value will be always added.
- If this multimap cache does not support duplicates and the value exists on the key, nothing will be done.
- Specified by:
putin interfaceBasicMultimapCache<K,V> - Parameters:
key- the key to be putvalue- the value to added- Returns:
CompletableFuturecontaining aVoid
-
get
Description copied from interface:BasicMultimapCacheReturns a view collection of the values associated with key in this multimap cache, if any. Any changes to the retrieved collection won't change the values in this multimap cache. When this method returns an empty collection, it means the key was not found.- Specified by:
getin interfaceBasicMultimapCache<K,V> - Parameters:
key- to be retrieved- Returns:
- a
CompletableFuturecontainingwhich is a view of the underlying values.
-
getEntry
Description copied from interface:MultimapCacheRetrieves a CacheEntry corresponding to a specific key in this multimap cache.- Specified by:
getEntryin interfaceMultimapCache<K,V> - Parameters:
key- the key whose associated cache entry is to be returned- Returns:
- the cache entry to which the specified key is mapped, or
Optional.empty()if this multimap contains no mapping for the key
-
remove
Description copied from interface:BasicMultimapCacheRemoves all the key-value pairs associated with the key from this multimap cache, if such exists.- Specified by:
removein interfaceBasicMultimapCache<K,V> - Parameters:
key- to be removed- Returns:
- a
CompletableFuturecontainingBoolean.TRUEif the entry was removed, andBoolean.FALSEwhen the entry was not removed
-
remove
Description copied from interface:BasicMultimapCacheRemoves a key-value pair from this multimap cache, if such exists. Returns true when the key-value pair has been removed from the key.- In the case where duplicates are not supported, only one the key-value pair will be removed, if such exists.
- In the case where duplicates are supported, all the key-value pairs will be removed.
- If the values remaining after the remove call are empty, the whole entry will be removed.
- Specified by:
removein interfaceBasicMultimapCache<K,V> - Parameters:
key- key to be removedvalue- value to be removed- Returns:
CompletableFuturecontainingBoolean.TRUEif the key-value pair was removed, andBoolean.FALSEwhen the key-value pair was not removed
-
remove
Description copied from interface:MultimapCacheAsynchronous method. Removes every value that match thePredicate.This method is blocking used in a explicit transaction context.
- Specified by:
removein interfaceMultimapCache<K,V> - Parameters:
p- the predicate to be tested on every value in this multimap cache- Returns:
CompletableFuturecontaining aVoid
-
containsKey
Description copied from interface:BasicMultimapCacheReturnsBoolean.TRUEif this multimap cache contains the key.- Specified by:
containsKeyin interfaceBasicMultimapCache<K,V> - Parameters:
key- the key that might exists in this multimap cache- Returns:
CompletableFuturecontaining aBoolean
-
containsValue
Description copied from interface:BasicMultimapCacheAsynchronous method that returnsBoolean.TRUEif this multimap cache contains the value at any key.- Specified by:
containsValuein interfaceBasicMultimapCache<K,V> - Parameters:
value- the value that might exists in any entry- Returns:
CompletableFuturecontaining aBoolean
-
containsEntry
Description copied from interface:BasicMultimapCacheReturnsBoolean.TRUEif this multimap cache contains the key-value pair.- Specified by:
containsEntryin interfaceBasicMultimapCache<K,V> - Parameters:
key- the key of the key-value pairvalue- the value of the key-value pair- Returns:
CompletableFuturecontaining aBoolean
-
size
Description copied from interface:BasicMultimapCacheReturns the number of key-value pairs in this multimap cache. It doesn't return the distinct number of keys.This method is blocking in a explicit transaction context.
The
CompletableFutureis a- Specified by:
sizein interfaceBasicMultimapCache<K,V> - Returns:
CompletableFuturecontaining the size asLong
-
supportsDuplicates
public boolean supportsDuplicates()Description copied from interface:BasicMultimapCacheMultimap can support duplicates on the same key k → ['a', 'a', 'b'] or not k → ['a', 'b'] depending on configuration.Returns duplicates are supported or not in this multimap cache.
- Specified by:
supportsDuplicatesin interfaceBasicMultimapCache<K,V> - Returns:
trueif this multimap supports duplicate values for a given key.
-
getCache
-