public interface BasicMultimapCache<K,V>
BasicMultimapCache provides the common API for the two different types of multimap caches that Infinispan
provides: embedded and remote. Please see the Infinispan documentation and/or the 5 Minute Usage Tutorial for more details on Infinispan.
MutimapCache is a type of Infinispan Cache that maps keys to values, similar to AsyncCache in which each key can contain multiple values.
foo -> 1
bar -> 3, 4, 5
multimapCache.put("k", "v1").join();
multimapCache.put("k", "v2").join();
multimapCache.put("k", "v3").join();
Collection results = multimapCache.get("k").join();
Eviction works per key. This means all the values associated on a key will be evicted.
The returned collections when calling "get" are views of the values on the key. Any change on these collections won't affect the cache values on the key.
Example
multimapCache.put(null, "v1").join() -> fails
multimapCache.put("k", null).join() -> fails
multimapCache.put("k", "v1").join() -> works and add's v1
multimapCache.containsKey("k").join() -> true
multimapCache.remove("k", "v1").join() -> works, removes v1 and as the remaining collection is empty, the key is
removed
multimapCache.containsKey("k").join() -> false
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
containsEntry(K key,
V value)
Returns
Boolean.TRUE if this multimap cache contains the key-value pair. |
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
containsKey(K key)
Returns
Boolean.TRUE if this multimap cache contains the key. |
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
containsValue(V value)
Asynchronous method that returns
Boolean.TRUE if this multimap cache contains the value at any key. |
java.util.concurrent.CompletableFuture<java.util.Collection<V>> |
get(K key)
Returns a view collection of the values associated with key in this multimap cache,
if any.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
put(K key,
V value)
Puts a key-value pair in this multimap cache.
|
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
remove(K key)
Removes all the key-value pairs associated with the key from this multimap cache, if such exists.
|
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
remove(K key,
V value)
Removes a key-value pair from this multimap cache, if such exists.
|
java.util.concurrent.CompletableFuture<java.lang.Long> |
size()
Returns the number of key-value pairs in this multimap cache.
|
boolean |
supportsDuplicates()
Multimap can support duplicates on the same key k -> ['a', 'a', 'b'] or not k -> ['a', 'b'] depending on
configuration.
|
java.util.concurrent.CompletableFuture<java.lang.Void> put(K key, V value)
key - the key to be putvalue - the value to addedCompletableFuture containing a Voidjava.util.concurrent.CompletableFuture<java.util.Collection<V>> get(K key)
key - to be retrievedCompletableFuture containing which is a view of the underlying values.java.util.concurrent.CompletableFuture<java.lang.Boolean> remove(K key)
key - to be removedCompletableFuture containing Boolean.TRUE if the entry was removed, and Boolean.FALSE when the entry was not removedjava.util.concurrent.CompletableFuture<java.lang.Boolean> remove(K key, V value)
key - key to be removedvalue - value to be removedCompletableFuture containing Boolean.TRUE if the key-value pair was removed, and Boolean.FALSE when the key-value pair was not removedjava.util.concurrent.CompletableFuture<java.lang.Boolean> containsKey(K key)
Boolean.TRUE if this multimap cache contains the key.key - the key that might exists in this multimap cacheCompletableFuture containing a Booleanjava.util.concurrent.CompletableFuture<java.lang.Boolean> containsValue(V value)
Boolean.TRUE if this multimap cache contains the value at any key.value - the value that might exists in any entryCompletableFuture containing a Booleanjava.util.concurrent.CompletableFuture<java.lang.Boolean> containsEntry(K key, V value)
Boolean.TRUE if this multimap cache contains the key-value pair.key - the key of the key-value pairvalue - the value of the key-value pairCompletableFuture containing a Booleanjava.util.concurrent.CompletableFuture<java.lang.Long> size()
This method is blocking in a explicit transaction context.
The CompletableFuture is a
CompletableFuture containing the size as Longboolean supportsDuplicates()
Returns duplicates are supported or not in this multimap cache.
true if this multimap supports duplicate values for a given key.