@Experimental 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(); Collectionresults = 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 |
---|---|
CompletableFuture<Boolean> |
containsEntry(K key,
V value)
Returns
Boolean.TRUE if this multimap cache contains the key-value pair. |
CompletableFuture<Boolean> |
containsKey(K key)
Returns
Boolean.TRUE if this multimap cache contains the key. |
CompletableFuture<Boolean> |
containsValue(V value)
Asynchronous method that returns
Boolean.TRUE if this multimap cache contains the value at any key. |
CompletableFuture<Collection<V>> |
get(K key)
Returns a view collection of the values associated with key in this multimap cache,
if any.
|
CompletableFuture<Void> |
put(K key,
V value)
Puts a key-value pair in this multimap cache.
|
CompletableFuture<Boolean> |
remove(K key)
Removes all the key-value pairs associated with the key from this multimap cache, if such exists.
|
CompletableFuture<Boolean> |
remove(K key,
V value)
Removes a key-value pair from this multimap cache, if such exists.
|
CompletableFuture<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.
|
CompletableFuture<Void> put(K key, V value)
key
- the key to be putvalue
- the value to addedCompletableFuture
containing a Void
CompletableFuture<Collection<V>> get(K key)
key
- to be retrievedCompletableFuture
containing
which is a view of the underlying values.CompletableFuture<Boolean> remove(K key)
key
- to be removedCompletableFuture
containing Boolean.TRUE
if the entry was removed, and Boolean.FALSE
when the entry was not removedCompletableFuture<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 removedCompletableFuture<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 Boolean
CompletableFuture<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 Boolean
CompletableFuture<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 Boolean
CompletableFuture<Long> size()
This method is blocking in a explicit transaction context.
The CompletableFuture
is a
CompletableFuture
containing the size as Long
boolean supportsDuplicates()
Returns duplicates are supported or not in this multimap cache.
true
if this multimap supports duplicate values for a given key.Copyright © 2021 JBoss by Red Hat. All rights reserved.