Class 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

    The current implementation does not support duplicate values on keys. Object.equals(Object) method is used to check if a value is already present in the key. This means that the following code.
        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 2. "k" -> ["v1", "v2"]
     
    Since:
    9.2
    Author:
    Katia Aresti, karesti@redhat.com
    • Constructor Detail

      • EmbeddedMultimapCache

        public EmbeddedMultimapCache​(org.infinispan.Cache<K,​Bucket<V>> cache)
    • Method Detail

      • put

        public CompletableFuture<Void> put​(K key,
                                           V value)
        Specified by:
        put 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>
      • 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()