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. invalid input: '{@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
-
Method Summary
Modifier and TypeMethodDescriptioncontainsEntry
(K key, V value) ReturnsBoolean.TRUE
if this multimap cache contains the key-value pair.containsKey
(K key) ReturnsBoolean.TRUE
if this multimap cache contains the key.containsValue
(V value) Asynchronous method that returnsBoolean.TRUE
if 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.boolean
Multimap 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, wait
Methods inherited from interface org.infinispan.multimap.api.embedded.MultimapCache
remove
-
Constructor Details
-
EmbeddedMultimapCache
-
-
Method Details
-
put
Description copied from interface:BasicMultimapCache
Puts 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:
put
in interfaceBasicMultimapCache<K,
V> - Parameters:
key
- the key to be putvalue
- the value to added- Returns:
CompletableFuture
containing aVoid
-
get
Description copied from interface:BasicMultimapCache
Returns 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:
get
in interfaceBasicMultimapCache<K,
V> - Parameters:
key
- to be retrieved- Returns:
- a
CompletableFuture
containing
which is a view of the underlying values.
-
getEntry
Description copied from interface:MultimapCache
Retrieves a CacheEntry corresponding to a specific key in this multimap cache.- Specified by:
getEntry
in 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:BasicMultimapCache
Removes all the key-value pairs associated with the key from this multimap cache, if such exists.- Specified by:
remove
in interfaceBasicMultimapCache<K,
V> - Parameters:
key
- to be removed- Returns:
- a
CompletableFuture
containingBoolean.TRUE
if the entry was removed, andBoolean.FALSE
when the entry was not removed
-
remove
Description copied from interface:BasicMultimapCache
Removes 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:
remove
in interfaceBasicMultimapCache<K,
V> - Parameters:
key
- key to be removedvalue
- value to be removed- Returns:
CompletableFuture
containingBoolean.TRUE
if the key-value pair was removed, andBoolean.FALSE
when the key-value pair was not removed
-
remove
Description copied from interface:MultimapCache
Asynchronous method. Removes every value that match thePredicate
.This method is blocking used in a explicit transaction context.
- Specified by:
remove
in interfaceMultimapCache<K,
V> - Parameters:
p
- the predicate to be tested on every value in this multimap cache- Returns:
CompletableFuture
containing aVoid
-
containsKey
Description copied from interface:BasicMultimapCache
ReturnsBoolean.TRUE
if this multimap cache contains the key.- Specified by:
containsKey
in interfaceBasicMultimapCache<K,
V> - Parameters:
key
- the key that might exists in this multimap cache- Returns:
CompletableFuture
containing aBoolean
-
containsValue
Description copied from interface:BasicMultimapCache
Asynchronous method that returnsBoolean.TRUE
if this multimap cache contains the value at any key.- Specified by:
containsValue
in interfaceBasicMultimapCache<K,
V> - Parameters:
value
- the value that might exists in any entry- Returns:
CompletableFuture
containing aBoolean
-
containsEntry
Description copied from interface:BasicMultimapCache
ReturnsBoolean.TRUE
if this multimap cache contains the key-value pair.- Specified by:
containsEntry
in interfaceBasicMultimapCache<K,
V> - Parameters:
key
- the key of the key-value pairvalue
- the value of the key-value pair- Returns:
CompletableFuture
containing aBoolean
-
size
Description copied from interface:BasicMultimapCache
Returns 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
CompletableFuture
is a- Specified by:
size
in interfaceBasicMultimapCache<K,
V> - Returns:
CompletableFuture
containing the size asLong
-
supportsDuplicates
public boolean supportsDuplicates()Description copied from interface:BasicMultimapCache
Multimap 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:
supportsDuplicates
in interfaceBasicMultimapCache<K,
V> - Returns:
true
if this multimap supports duplicate values for a given key.
-
getCache
-