Class EmbeddedMultimapCache<K,V>

java.lang.Object
org.infinispan.multimap.impl.EmbeddedMultimapCache<K,V>
All Implemented Interfaces:
org.infinispan.multimap.api.BasicMultimapCache<K,V>, MultimapCache<K,V>

public class EmbeddedMultimapCache<K,V> extends Object implements 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 :
  • BasicMultimapCache.size()
  • BasicMultimapCache.containsEntry(Object, Object)
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 Details

    • EmbeddedMultimapCache

      public EmbeddedMultimapCache(org.infinispan.Cache<K,Bucket<V>> cache, boolean supportsDuplicates)
  • Method Details

    • put

      public CompletableFuture<Void> put(K key, V value)
      Specified by:
      put in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • get

      public CompletableFuture<Collection<V>> get(K key)
      Specified by:
      get in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • getEntry

      public CompletableFuture<Optional<org.infinispan.container.entries.CacheEntry<K,Collection<V>>>> getEntry(K key)
      Description copied from interface: MultimapCache
      Retrieves a CacheEntry corresponding to a specific key in this multimap cache.
      Specified by:
      getEntry in interface MultimapCache<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

      public CompletableFuture<Boolean> remove(K key)
      Specified by:
      remove in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • remove

      public CompletableFuture<Boolean> remove(K key, V value)
      Specified by:
      remove in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • remove

      public CompletableFuture<Void> remove(Predicate<? super V> p)
      Description copied from interface: MultimapCache
      Asynchronous method. Removes every value that match the Predicate.

      This method is blocking used in a explicit transaction context.

      Specified by:
      remove in interface MultimapCache<K,V>
      Parameters:
      p - the predicate to be tested on every value in this multimap cache
      Returns:
      CompletableFuture containing a Void
    • containsKey

      public CompletableFuture<Boolean> containsKey(K key)
      Specified by:
      containsKey in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • containsValue

      public CompletableFuture<Boolean> containsValue(V value)
      Specified by:
      containsValue in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • containsEntry

      public CompletableFuture<Boolean> containsEntry(K key, V value)
      Specified by:
      containsEntry in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • size

      public CompletableFuture<Long> size()
      Specified by:
      size in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • supportsDuplicates

      public boolean supportsDuplicates()
      Specified by:
      supportsDuplicates in interface org.infinispan.multimap.api.BasicMultimapCache<K,V>
    • getCache

      public org.infinispan.Cache<K,Bucket<V>> getCache()