Class EncoderCache<K,​V>

  • All Implemented Interfaces:
    ConcurrentMap<K,​V>, Map<K,​V>, AdvancedCache<K,​V>, Cache<K,​V>, org.infinispan.commons.api.AsyncCache<K,​V>, org.infinispan.commons.api.BasicCache<K,​V>, org.infinispan.commons.api.BatchingCache, org.infinispan.commons.api.Lifecycle, org.infinispan.commons.api.TransactionalCache, FilteringListenable<K,​V>, Listenable

    public class EncoderCache<K,​V>
    extends AbstractDelegatingAdvancedCache<K,​V>
    Cache decoration that makes use of the Encoder and Wrapper to convert between storage value and read/write value.
    Since:
    9.1
    • Method Detail

      • keyToStorage

        public K keyToStorage​(Object key)
      • valueToStorage

        public V valueToStorage​(Object value)
      • keyFromStorage

        public K keyFromStorage​(Object key)
      • valueFromStorage

        public V valueFromStorage​(Object value)
      • wireRealCache

        public void wireRealCache()
      • putForExternalRead

        public void putForExternalRead​(K key,
                                       V value)
        Description copied from interface: Cache
        Under special operating behavior, associates the value with the specified key.
        • Only goes through if the key specified does not exist; no-op otherwise (similar to ConcurrentMap.putIfAbsent(Object, Object))
        • Force asynchronous mode for replication to prevent any blocking.
        • invalidation does not take place.
        • 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this method is a no-op, and swallows the timeout exception.
        • Ongoing transactions are suspended before this call, so failures here will not affect any ongoing transactions.
        • Errors and exceptions are 'silent' - logged at a much lower level than normal, and this method does not throw exceptions
        This method is for caching data that has an external representation in storage, where, concurrent modification and transactions are not a consideration, and failure to put the data in the cache should be treated as a 'suboptimal outcome' rather than a 'failing outcome'.

        An example of when this method is useful is when data is read from, for example, a legacy datastore, and is cached before returning the data to the caller. Subsequent calls would prefer to get the data from the cache and if the data doesn't exist in the cache, fetch again from the legacy datastore.

        See JBCACHE-848 for details around this feature.

        Specified by:
        putForExternalRead in interface Cache<K,​V>
        Overrides:
        putForExternalRead in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key with which the specified value is to be associated.
        value - value to be associated with the specified key.
      • putForExternalRead

        public void putForExternalRead​(K key,
                                       V value,
                                       long lifespan,
                                       TimeUnit unit)
        Description copied from interface: Cache
        An overloaded form of #putForExternalRead(K, V), which takes in lifespan parameters.
        Specified by:
        putForExternalRead in interface Cache<K,​V>
        Overrides:
        putForExternalRead in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        unit - unit of measurement for the lifespan
      • putForExternalRead

        public void putForExternalRead​(K key,
                                       V value,
                                       long lifespan,
                                       TimeUnit lifespanUnit,
                                       long maxIdle,
                                       TimeUnit maxIdleUnit)
        Description copied from interface: Cache
        An overloaded form of #putForExternalRead(K, V), which takes in lifespan parameters.
        Specified by:
        putForExternalRead in interface Cache<K,​V>
        Overrides:
        putForExternalRead in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleUnit - time unit for max idle time
      • evict

        public void evict​(K key)
        Description copied from interface: Cache
        Evicts an entry from the memory of the cache. Note that the entry is not removed from any configured cache stores or any other caches in the cluster (if used in a clustered mode). Use BasicCache.remove(Object) to remove an entry from the entire cache system.

        This method is designed to evict an entry from memory to free up memory used by the application. This method uses a 0 lock acquisition timeout so it does not block in attempting to acquire locks. It behaves as a no-op if the lock on the entry cannot be acquired immediately.

        Important: this method should not be called from within a transaction scope.

        Specified by:
        evict in interface Cache<K,​V>
        Overrides:
        evict in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to evict
      • put

        public V put​(K key,
                     V value,
                     long lifespan,
                     TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of BasicCache.put(Object, Object), which takes in lifespan parameters.
        Specified by:
        put in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        put in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        unit - unit of measurement for the lifespan
        Returns:
        the value being replaced, or null if nothing is being replaced.
      • putIfAbsent

        public V putIfAbsent​(K key,
                             V value,
                             long lifespan,
                             TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.
        Specified by:
        putIfAbsent in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        putIfAbsent in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        unit - unit of measurement for the lifespan
        Returns:
        the value being replaced, or null if nothing is being replaced.
      • putAll

        public void putAll​(Map<? extends K,​? extends V> map,
                           long lifespan,
                           TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of Map.putAll(Map), which takes in lifespan parameters. Note that the lifespan is applied to all mappings in the map passed in.
        Specified by:
        putAll in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        putAll in class AbstractDelegatingCache<K,​V>
        Parameters:
        map - map containing mappings to enter
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        unit - unit of measurement for the lifespan
      • replace

        public V replace​(K key,
                         V value,
                         long lifespan,
                         TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        replace in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        unit - unit of measurement for the lifespan
        Returns:
        the value being replaced, or null if nothing is being replaced.
      • replace

        public boolean replace​(K key,
                               V oldValue,
                               V value,
                               long lifespan,
                               TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        replace in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        oldValue - value to replace
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        unit - unit of measurement for the lifespan
        Returns:
        true if the value was replaced, false otherwise
      • put

        public V put​(K key,
                     V value,
                     long lifespan,
                     TimeUnit lifespanUnit,
                     long maxIdleTime,
                     TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of BasicCache.put(Object, Object), which takes in lifespan parameters.
        Specified by:
        put in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        put in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
        Returns:
        the value being replaced, or null if nothing is being replaced.
      • putIfAbsent

        public V putIfAbsent​(K key,
                             V value,
                             long lifespan,
                             TimeUnit lifespanUnit,
                             long maxIdleTime,
                             TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.
        Specified by:
        putIfAbsent in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        putIfAbsent in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
        Returns:
        the value being replaced, or null if nothing is being replaced.
      • putAll

        public void putAll​(Map<? extends K,​? extends V> map,
                           long lifespan,
                           TimeUnit lifespanUnit,
                           long maxIdleTime,
                           TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of Map.putAll(Map), which takes in lifespan parameters. Note that the lifespan is applied to all mappings in the map passed in.
        Specified by:
        putAll in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        putAll in class AbstractDelegatingCache<K,​V>
        Parameters:
        map - map containing mappings to enter
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
      • replace

        public V replace​(K key,
                         V value,
                         long lifespan,
                         TimeUnit lifespanUnit,
                         long maxIdleTime,
                         TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        replace in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
        Returns:
        the value being replaced, or null if nothing is being replaced.
      • replace

        public boolean replace​(K key,
                               V oldValue,
                               V value,
                               long lifespan,
                               TimeUnit lifespanUnit,
                               long maxIdleTime,
                               TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        replace in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        oldValue - value to replace
        value - value to store
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
        Returns:
        true if the value was replaced, false otherwise
      • putAsync

        public CompletableFuture<V> putAsync​(K key,
                                             V value)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.put(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        Returns:
        a future containing the old value replaced.
      • putAsync

        public CompletableFuture<V> putAsync​(K key,
                                             V value,
                                             long lifespan,
                                             TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.put(Object, Object, long, TimeUnit) . This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of entry
        unit - time unit for lifespan
        Returns:
        a future containing the old value replaced
      • putAsync

        public CompletableFuture<V> putAsync​(K key,
                                             V value,
                                             long lifespan,
                                             TimeUnit lifespanUnit,
                                             long maxIdle,
                                             TimeUnit maxIdleUnit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.put(Object, Object, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of entry
        lifespanUnit - time unit for lifespan
        maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleUnit - time unit for max idle time
        Returns:
        a future containing the old value replaced
      • putAllAsync

        public CompletableFuture<Void> putAllAsync​(Map<? extends K,​? extends V> data)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of Map.putAll(Map). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putAllAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putAllAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        data - to store
        Returns:
        a future containing a void return type
      • putAllAsync

        public CompletableFuture<Void> putAllAsync​(Map<? extends K,​? extends V> data,
                                                   long lifespan,
                                                   TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.putAll(Map, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putAllAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putAllAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        data - to store
        lifespan - lifespan of entry
        unit - time unit for lifespan
        Returns:
        a future containing a void return type
      • putAllAsync

        public CompletableFuture<Void> putAllAsync​(Map<? extends K,​? extends V> data,
                                                   long lifespan,
                                                   TimeUnit lifespanUnit,
                                                   long maxIdle,
                                                   TimeUnit maxIdleUnit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.putAll(Map, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putAllAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putAllAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        data - to store
        lifespan - lifespan of entry
        lifespanUnit - time unit for lifespan
        maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleUnit - time unit for max idle time
        Returns:
        a future containing a void return type
      • putIfAbsentAsync

        public CompletableFuture<V> putIfAbsentAsync​(K key,
                                                     V value)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of ConcurrentMap.putIfAbsent(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putIfAbsentAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        Returns:
        a future containing the old value replaced.
      • putIfAbsentAsync

        public CompletableFuture<V> putIfAbsentAsync​(K key,
                                                     V value,
                                                     long lifespan,
                                                     TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.putIfAbsent(Object, Object, long, TimeUnit) . This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putIfAbsentAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of entry
        unit - time unit for lifespan
        Returns:
        a future containing the old value replaced
      • lock

        public boolean lock​(K... keys)
        Description copied from interface: AdvancedCache
        Locks a given key or keys eagerly across cache nodes in a cluster.

        Keys can be locked eagerly in the context of a transaction only.

        Specified by:
        lock in interface AdvancedCache<K,​V>
        Overrides:
        lock in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        keys - the keys to lock
        Returns:
        true if the lock acquisition attempt was successful for all keys; false will only be returned if the lock acquisition timed out and the operation has been called with Flag.FAIL_SILENTLY.
      • lock

        public boolean lock​(Collection<? extends K> keys)
        Description copied from interface: AdvancedCache
        Locks collections of keys eagerly across cache nodes in a cluster.

        Collections of keys can be locked eagerly in the context of a transaction only.

        Specified by:
        lock in interface AdvancedCache<K,​V>
        Overrides:
        lock in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        keys - collection of keys to lock
        Returns:
        true if the lock acquisition attempt was successful for all keys; false will only be returned if the lock acquisition timed out and the operation has been called with Flag.FAIL_SILENTLY.
      • putIfAbsentAsync

        public CompletableFuture<V> putIfAbsentAsync​(K key,
                                                     V value,
                                                     long lifespan,
                                                     TimeUnit lifespanUnit,
                                                     long maxIdle,
                                                     TimeUnit maxIdleUnit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        putIfAbsentAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        lifespan - lifespan of entry
        lifespanUnit - time unit for lifespan
        maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleUnit - time unit for max idle time
        Returns:
        a future containing the old value replaced
      • putIfAbsentAsync

        public CompletableFuture<V> putIfAbsentAsync​(K key,
                                                     V value,
                                                     Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #putIfAbsentAsync(K, V), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        putIfAbsentAsync in interface AdvancedCache<K,​V>
        Overrides:
        putIfAbsentAsync in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        metadata - information to store alongside the new value
        Returns:
        A future containing the previous value associated with the specified key, or null if there was no mapping for the key.
      • removeAsync

        public CompletableFuture<V> removeAsync​(Object key)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.remove(Object). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        removeAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        removeAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to remove
        Returns:
        a future containing the value removed
      • removeAsync

        public CompletableFuture<Boolean> removeAsync​(Object key,
                                                      Object value)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of ConcurrentMap.remove(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        removeAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        removeAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to remove
        value - value to match on
        Returns:
        a future containing a boolean, indicating whether the entry was removed or not
      • replaceAsync

        public CompletableFuture<V> replaceAsync​(K key,
                                                 V value)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of ConcurrentMap.replace(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        replaceAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to remove
        value - value to store
        Returns:
        a future containing the previous value overwritten
      • replaceAsync

        public CompletableFuture<V> replaceAsync​(K key,
                                                 V value,
                                                 long lifespan,
                                                 TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.replace(Object, Object, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        replaceAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to remove
        value - value to store
        lifespan - lifespan of entry
        unit - time unit for lifespan
        Returns:
        a future containing the previous value overwritten
      • replaceAsync

        public CompletableFuture<V> replaceAsync​(K key,
                                                 V value,
                                                 Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #replaceAsync(K, V), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        replaceAsync in interface AdvancedCache<K,​V>
        Overrides:
        replaceAsync in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is associated
        value - value to be associated with the specified key
        metadata - information to store alongside the new value
        Returns:
        the future that contains previous value associated with the specified key, or null if there was no mapping for the key.
      • getAll

        public Map<K,​V> getAll​(Set<?> keys)
        Description copied from interface: AdvancedCache
        Gets a collection of entries, returning them as Map of the values associated with the set of keys requested.

        If the cache is configured read-through, and a get for a key would return null because an entry is missing from the cache, the Cache's CacheLoader is called in an attempt to load the entry. If an entry cannot be loaded for a given key, the returned Map will contain null for value of the key.

        Unlike other bulk methods if this invoked in an existing transaction all entries will be stored in the current transactional context

        The returned Map will be a copy and updates to the map will not be reflected in the Cache and vice versa. The keys and values themselves however may not be copies depending on if storeAsBinary is enabled and the value was retrieved from the local node.

        Specified by:
        getAll in interface AdvancedCache<K,​V>
        Overrides:
        getAll in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        keys - The keys whose associated values are to be returned.
        Returns:
        A map of entries that were found for the given keys. If an entry is not found for a given key, it will not be in the returned map.
      • replaceAsync

        public CompletableFuture<V> replaceAsync​(K key,
                                                 V value,
                                                 long lifespan,
                                                 TimeUnit lifespanUnit,
                                                 long maxIdle,
                                                 TimeUnit maxIdleUnit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.replace(Object, Object, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        replaceAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to remove
        value - value to store
        lifespan - lifespan of entry
        lifespanUnit - time unit for lifespan
        maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleUnit - time unit for max idle time
        Returns:
        a future containing the previous value overwritten
      • getAllCacheEntries

        public Map<K,​CacheEntry<K,​V>> getAllCacheEntries​(Set<?> keys)
        Description copied from interface: AdvancedCache
        Gets a collection of entries from the AdvancedCache, returning them as Map of the cache entries associated with the set of keys requested.

        If the cache is configured read-through, and a get for a key would return null because an entry is missing from the cache, the Cache's CacheLoader is called in an attempt to load the entry. If an entry cannot be loaded for a given key, the returned Map will contain null for value of the key.

        Unlike other bulk methods if this invoked in an existing transaction all entries will be stored in the current transactional context

        The returned Map will be a copy and updates to the map will not be reflected in the Cache and vice versa. The keys and values themselves however may not be copies depending on if storeAsBinary is enabled and the value was retrieved from the local node.

        Specified by:
        getAllCacheEntries in interface AdvancedCache<K,​V>
        Overrides:
        getAllCacheEntries in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        keys - The keys whose associated values are to be returned.
        Returns:
        A map of entries that were found for the given keys. Keys not found in the cache are present in the map with null values.
      • getGroup

        public Map<K,​V> getGroup​(String groupName)
        Description copied from interface: AdvancedCache
        It fetches all the keys which belong to the group.

        Semantically, it iterates over all the keys in memory and persistence, and performs a read operation in the keys found. Multiple invocations inside a transaction ensures that all the keys previous read are returned and it may return newly added keys to the group from other committed transactions (also known as phantom reads).

        The map returned is immutable and represents the group at the time of the invocation. If you want to add or remove keys from a group use BasicCache.put(Object, Object) and BasicCache.remove(Object). To remove all the keys in the group use AdvancedCache.removeGroup(String).

        To improve performance you may use the flag Flag.SKIP_CACHE_LOAD to avoid fetching the key/value from persistence. However, you will get an inconsistent snapshot of the group.

        Specified by:
        getGroup in interface AdvancedCache<K,​V>
        Overrides:
        getGroup in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        groupName - the group name.
        Returns:
        an immutable Map with the key/value pairs.
      • replaceAsync

        public CompletableFuture<Boolean> replaceAsync​(K key,
                                                       V oldValue,
                                                       V newValue)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of ConcurrentMap.replace(Object, Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        replaceAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to remove
        oldValue - value to overwrite
        newValue - value to store
        Returns:
        a future containing a boolean, indicating whether the entry was replaced or not
      • replaceAsync

        public CompletableFuture<Boolean> replaceAsync​(K key,
                                                       V oldValue,
                                                       V newValue,
                                                       long lifespan,
                                                       TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.replace(Object, Object, Object, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        replaceAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to remove
        oldValue - value to overwrite
        newValue - value to store
        lifespan - lifespan of entry
        unit - time unit for lifespan
        Returns:
        a future containing a boolean, indicating whether the entry was replaced or not
      • put

        public V put​(K key,
                     V value,
                     Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #put(K, V), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.
        Specified by:
        put in interface AdvancedCache<K,​V>
        Overrides:
        put in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key to use
        value - value to store
        metadata - information to store alongside the value
        Returns:
        the previous value associated with key, or null if there was no mapping for key.
      • replace

        public V replace​(K key,
                         V value,
                         Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #replace(K, V), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        replace in interface AdvancedCache<K,​V>
        Overrides:
        replace in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is associated
        value - value to be associated with the specified key
        metadata - information to store alongside the new value
        Returns:
        the previous value associated with the specified key, or null if there was no mapping for the key.
      • replaceAsync

        public CompletableFuture<Boolean> replaceAsync​(K key,
                                                       V oldValue,
                                                       V newValue,
                                                       long lifespan,
                                                       TimeUnit lifespanUnit,
                                                       long maxIdle,
                                                       TimeUnit maxIdleUnit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.replace(Object, Object, Object, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        replaceAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to remove
        oldValue - value to overwrite
        newValue - value to store
        lifespan - lifespan of entry
        lifespanUnit - time unit for lifespan
        maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleUnit - time unit for max idle time
        Returns:
        a future containing a boolean, indicating whether the entry was replaced or not
      • replace

        public boolean replace​(K key,
                               V oldValue,
                               V value,
                               Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #replace(K, V, V), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        replace in interface AdvancedCache<K,​V>
        Overrides:
        replace in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is associated
        oldValue - value expected to be associated with the specified key
        value - value to be associated with the specified key
        metadata - information to store alongside the new value
        Returns:
        true if the value was replaced
      • putIfAbsent

        public V putIfAbsent​(K key,
                             V value,
                             Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #putIfAbsent(K, V), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        putIfAbsent in interface AdvancedCache<K,​V>
        Overrides:
        putIfAbsent in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        metadata - information to store alongside the new value
        Returns:
        the previous value associated with the specified key, or null if there was no mapping for the key.
      • putForExternalRead

        public void putForExternalRead​(K key,
                                       V value,
                                       Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #putForExternalRead(K, V), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        putForExternalRead in interface AdvancedCache<K,​V>
        Overrides:
        putForExternalRead in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        metadata - information to store alongside the new value
      • putAll

        public void putAll​(Map<? extends K,​? extends V> map,
                           Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of Map.putAll(Map), which takes in an instance of Metadata which can be used to provide metadata information for the entries being stored, such as lifespan, version of value...etc.
        Specified by:
        putAll in interface AdvancedCache<K,​V>
        Overrides:
        putAll in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        map - the values to store
        metadata - information to store alongside the value(s)
      • removeLifespanExpired

        public CompletableFuture<Boolean> removeLifespanExpired​(K key,
                                                                V value,
                                                                Long lifespan)
        Description copied from interface: AdvancedCache
        Attempts to remove the entry if it is expired. Due to expired entries not being consistent across nodes, this will still attempt to remove the value if it is not present. Note that this will raise an expired event even if the entry is not present. Normally this method should never be invoked except by the ExpirationManager.

        This command will only remove the value if the value and lifespan also match if provided.

        This method will suspend any ongoing transaction and start a new one just for the invocation of this command. It is automatically committed or rolled back after the command completes, either successfully or via an exception.

        NOTE: This method may be removed at any point including in a minor release and is not supported for external usage.

        Specified by:
        removeLifespanExpired in interface AdvancedCache<K,​V>
        Overrides:
        removeLifespanExpired in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - the key that is expiring
        value - the value that mapped to the given. Null means it will match any value
        lifespan - the lifespan that should match. If null is provided it will match any lifespan value
        Returns:
        if the entry was removed
      • removeMaxIdleExpired

        public CompletableFuture<Boolean> removeMaxIdleExpired​(K key,
                                                               V value)
        Description copied from interface: AdvancedCache
        Attempts to remove the entry for the given key, if it has expired due to max idle. This command first locks the key and then verifies that the entry has expired via maxIdle across all nodes. If it has this will then remove the given key.

        This method returns a boolean when it has determined if the entry has expired. This is useful for when a backup node invokes this command for a get that found the entry expired. This way the node can return back to the caller much faster when the entry is not expired and do any additional processing asynchronously if needed.

        This method will suspend any ongoing transaction and start a new one just for the invocation of this command. It is automatically committed or rolled back after the command completes, either successfully or via an exception.

        NOTE: This method may be removed at any point including in a minor release and is not supported for external usage.

        Specified by:
        removeMaxIdleExpired in interface AdvancedCache<K,​V>
        Overrides:
        removeMaxIdleExpired in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - the key that expired via max idle for the given entry
        Returns:
        if the entry was removed
      • withEncoding

        public AdvancedCache<K,​V> withEncoding​(Class<? extends org.infinispan.commons.dataconversion.Encoder> keyEncoderClass,
                                                     Class<? extends org.infinispan.commons.dataconversion.Encoder> valueEncoderClass)
        Description copied from interface: AdvancedCache
        Performs any cache operations using the specified pair of Encoder.
        Specified by:
        withEncoding in interface AdvancedCache<K,​V>
        Overrides:
        withEncoding in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        keyEncoderClass - Encoder for the keys.
        valueEncoderClass - Encoder for the values.
        Returns:
        an instance of AdvancedCache where all operations will use the supplied encoders.
      • withWrapping

        public AdvancedCache<K,​V> withWrapping​(Class<? extends org.infinispan.commons.dataconversion.Wrapper> keyWrapperClass,
                                                     Class<? extends org.infinispan.commons.dataconversion.Wrapper> valueWrapperClass)
        Description copied from interface: AdvancedCache
        Performs any cache operations using the specified pair of Wrapper.
        Specified by:
        withWrapping in interface AdvancedCache<K,​V>
        Overrides:
        withWrapping in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        keyWrapperClass - Wrapper for the keys.
        valueWrapperClass - Wrapper for the values.
        Returns:
        AdvancedCache where all operations will use the supplied wrappers.
      • compute

        public V compute​(K key,
                         BiFunction<? super K,​? super V,​? extends V> remappingFunction)
        Description copied from interface: Cache

        When this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate Externalizer or be Serializable itself.

        For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.

        Specified by:
        compute in interface Cache<K,​V>
        Specified by:
        compute in interface ConcurrentMap<K,​V>
        Specified by:
        compute in interface Map<K,​V>
        Overrides:
        compute in class AbstractDelegatingCache<K,​V>
      • compute

        public V compute​(K key,
                         BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                         Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #compute(K, BiFunction), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.
        Specified by:
        compute in interface AdvancedCache<K,​V>
        Overrides:
        compute in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is associated
        remappingFunction - function to be applied to the specified key/value
        metadata - information to store alongside the new value
        Returns:
        the previous value associated with the specified key, or null if remapping function is gives null.
      • compute

        public V compute​(K key,
                         BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                         long lifespan,
                         TimeUnit lifespanUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.compute(Object, BiFunction) which takes in lifespan parameters.
        Specified by:
        compute in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        compute in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        remappingFunction - function to use to compute and store the value under key
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        Returns:
        the computed value that was stored under key
      • compute

        public V compute​(K key,
                         BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                         long lifespan,
                         TimeUnit lifespanUnit,
                         long maxIdleTime,
                         TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.compute(Object, BiFunction) which takes in lifespan and maxIdleTime parameters.
        Specified by:
        compute in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        compute in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        remappingFunction - function to use to compute and store the value under key
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
        Returns:
        the computed value that was stored under key
      • computeIfPresent

        public V computeIfPresent​(K key,
                                  BiFunction<? super K,​? super V,​? extends V> remappingFunction)
        Description copied from interface: Cache

        When this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate Externalizer or be Serializable itself.

        For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.

        Specified by:
        computeIfPresent in interface Cache<K,​V>
        Specified by:
        computeIfPresent in interface ConcurrentMap<K,​V>
        Specified by:
        computeIfPresent in interface Map<K,​V>
        Overrides:
        computeIfPresent in class AbstractDelegatingCache<K,​V>
      • computeIfPresent

        public V computeIfPresent​(K key,
                                  BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                                  Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #computeIfPresent(K, BiFunction), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        computeIfPresent in interface AdvancedCache<K,​V>
        Overrides:
        computeIfPresent in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is associated
        remappingFunction - function to be applied to the specified key/value
        metadata - information to store alongside the new value
        Returns:
        the previous value associated with the specified key, or null if there was no mapping for the key.
      • computeIfPresent

        public V computeIfPresent​(K key,
                                  BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                                  long lifespan,
                                  TimeUnit lifespanUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.computeIfPresent(Object, BiFunction) which takes in lifespan parameters.
        Specified by:
        computeIfPresent in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        computeIfPresent in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        remappingFunction - function to use to compute and store the value under key, if such exists
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        Returns:
        the computed value that was stored under key
      • computeIfPresent

        public V computeIfPresent​(K key,
                                  BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                                  long lifespan,
                                  TimeUnit lifespanUnit,
                                  long maxIdleTime,
                                  TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.computeIfPresent(Object, BiFunction) which takes in lifespan and maxIdleTime parameters.
        Specified by:
        computeIfPresent in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        computeIfPresent in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        remappingFunction - function to use to compute and store the value under key, if such exists
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
        Returns:
        the computed value that was stored under key
      • computeIfAbsent

        public V computeIfAbsent​(K key,
                                 Function<? super K,​? extends V> mappingFunction)
        Description copied from interface: Cache

        When this method is used on a clustered cache, either replicated or distributed, the function will be serialized to owning nodes to perform the operation in the most performant way. However this means the function must have an appropriate Externalizer or be Serializable itself.

        For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.

        Specified by:
        computeIfAbsent in interface Cache<K,​V>
        Specified by:
        computeIfAbsent in interface ConcurrentMap<K,​V>
        Specified by:
        computeIfAbsent in interface Map<K,​V>
        Overrides:
        computeIfAbsent in class AbstractDelegatingCache<K,​V>
      • computeIfAbsent

        public V computeIfAbsent​(K key,
                                 Function<? super K,​? extends V> mappingFunction,
                                 Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of #computeIfAbsent(K, Function), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        computeIfAbsent in interface AdvancedCache<K,​V>
        Overrides:
        computeIfAbsent in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - key with which the specified value is associated
        mappingFunction - function to be applied to the specified key
        metadata - information to store alongside the new value
        Returns:
        the value created with the mapping function associated with the specified key, or the previous value associated with the specified key if the key is not absent.
      • computeIfAbsent

        public V computeIfAbsent​(K key,
                                 Function<? super K,​? extends V> mappingFunction,
                                 long lifespan,
                                 TimeUnit lifespanUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.computeIfAbsent(Object, Function) which takes in lifespan parameters.
        Specified by:
        computeIfAbsent in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        computeIfAbsent in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        mappingFunction - function to use to compute and store the value under key, if the key is absent
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        Returns:
        the computed value that was stored under key
      • computeIfAbsent

        public V computeIfAbsent​(K key,
                                 Function<? super K,​? extends V> mappingFunction,
                                 long lifespan,
                                 TimeUnit lifespanUnit,
                                 long maxIdleTime,
                                 TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.computeIfAbsent(Object, Function) which takes in lifespan and maxIdleTime parameters.
        Specified by:
        computeIfAbsent in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        computeIfAbsent in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        mappingFunction - function to use to compute and store the value under key, if the key is absent
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
        Returns:
        the computed value that was stored under key
      • put

        public V put​(K key,
                     V value)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        If the return value of this operation will be ignored by the application, the user is strongly encouraged to use the Flag.IGNORE_RETURN_VALUES flag when invoking this method in order to make it behave as efficiently as possible (i.e. avoiding needless remote or network calls).
        Specified by:
        put in interface org.infinispan.commons.api.BasicCache<K,​V>
        Specified by:
        put in interface Map<K,​V>
        Overrides:
        put in class AbstractDelegatingCache<K,​V>
      • remove

        public V remove​(Object key)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        If the return value of this operation will be ignored by the application, the user is strongly encouraged to use the Flag.IGNORE_RETURN_VALUES flag when invoking this method in order to make it behave as efficiently as possible (i.e. avoiding needless remote or network calls).
        Specified by:
        remove in interface org.infinispan.commons.api.BasicCache<K,​V>
        Specified by:
        remove in interface Map<K,​V>
        Overrides:
        remove in class AbstractDelegatingCache<K,​V>
      • merge

        public V merge​(K key,
                       V value,
                       BiFunction<? super V,​? super V,​? extends V> remappingFunction)
        Description copied from interface: Cache

        When this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate Externalizer or be Serializable itself.

        For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.

        Specified by:
        merge in interface Cache<K,​V>
        Specified by:
        merge in interface ConcurrentMap<K,​V>
        Specified by:
        merge in interface Map<K,​V>
        Overrides:
        merge in class AbstractDelegatingCache<K,​V>
      • merge

        public V merge​(K key,
                       V value,
                       BiFunction<? super V,​? super V,​? extends V> remappingFunction,
                       Metadata metadata)
        Description copied from interface: AdvancedCache
        An overloaded form of Cache.merge(Object, Object, BiFunction), which takes in an instance of Metadata which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata is only stored if the call is successful.
        Specified by:
        merge in interface AdvancedCache<K,​V>
        Overrides:
        merge in class AbstractDelegatingAdvancedCache<K,​V>
        Parameters:
        key - , key with which the resulting value is to be associated
        value - , the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key
        remappingFunction - , the function to recompute a value if present
        metadata - , information to store alongside the new value
        Returns:
        the new value associated with the specified key, or null if no value is associated with the key
      • merge

        public V merge​(K key,
                       V value,
                       BiFunction<? super V,​? super V,​? extends V> remappingFunction,
                       long lifespan,
                       TimeUnit lifespanUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.merge(Object, Object, BiFunction) which takes in lifespan parameters.
        Specified by:
        merge in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        merge in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - new value to merge with existing value
        remappingFunction - function to use to merge new and existing values into a merged value to store under key
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        Returns:
        the merged value that was stored under key
      • merge

        public V merge​(K key,
                       V value,
                       BiFunction<? super V,​? super V,​? extends V> remappingFunction,
                       long lifespan,
                       TimeUnit lifespanUnit,
                       long maxIdleTime,
                       TimeUnit maxIdleTimeUnit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.merge(Object, Object, BiFunction) which takes in lifespan parameters.
        Specified by:
        merge in interface org.infinispan.commons.api.BasicCache<K,​V>
        Overrides:
        merge in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to use
        value - new value to merge with existing value
        remappingFunction - function to use to merge new and existing values into a merged value to store under key
        lifespan - lifespan of the entry. Negative values are interpreted as unlimited lifespan.
        lifespanUnit - time unit for lifespan
        maxIdleTime - the maximum amount of time this key is allowed to be idle for before it is considered as expired
        maxIdleTimeUnit - time unit for max idle time
        Returns:
        the merged value that was stored under key
      • keySet

        public CacheSet<K> keySet()
        Description copied from interface: Cache
        Returns a set view of the keys contained in this cache and cache loader across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing set is just returned. Invocation on the set itself is when the various operations are ran.

        Unsupported Operations

        Care should be taken when invoking Set.toArray(), Set.toArray(Object[]), Set.size(), Set.retainAll(Collection) and Set.iterator() methods as they will traverse the entire contents of the cluster including a configured CacheLoader and remote entries. The former 2 methods especially have a very high likely hood of causing a OutOfMemoryError due to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operations

        Supported Flags

        Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets.

        If there are performance concerns then the Flag.SKIP_CACHE_LOAD flag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to prevent OutOfMemoryError)

        Also if you want the local contents only you can use the Flag.CACHE_MODE_LOCAL flag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentioned Flag.SKIP_CACHE_LOAD is also configured.

        Iterator Use

        This class implements the CloseableIteratorSet interface which creates a CloseableIterator instead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.

        Unsupported Operations

        Due to not being able to add null values the following methods are not supported and will throw UnsupportedOperationException if invoked. Set.add(Object) Set.addAll(java.util.Collection)
        Specified by:
        keySet in interface Cache<K,​V>
        Specified by:
        keySet in interface Map<K,​V>
        Overrides:
        keySet in class AbstractDelegatingCache<K,​V>
        Returns:
        a set view of the keys contained in this cache and cache loader across the entire cluster.
      • entrySet

        public CacheSet<Map.Entry<K,​V>> entrySet()
        Description copied from interface: Cache
        Returns a set view of the mappings contained in this cache and cache loader across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing set is just returned. Invocation on the set itself is when the various operations are ran.

        Care should be taken when invoking Set.toArray(), Set.toArray(Object[]), Set.size(), Set.retainAll(Collection) and Set.iterator() methods as they will traverse the entire contents of the cluster including a configured CacheLoader and remote entries. The former 2 methods especially have a very high likely hood of causing a OutOfMemoryError due to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operations

        *

        Supported Flags

        Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets.

        If there are performance concerns then the Flag.SKIP_CACHE_LOAD flag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to prevent OutOfMemoryError)

        Also if you want the local contents only you can use the Flag.CACHE_MODE_LOCAL flag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentioned Flag.SKIP_CACHE_LOAD is also configured.

        Modifying or Adding Entries

        An entry's value is supported to be modified by using the Map.Entry.setValue(Object) and it will update the cache as well. Also this backing set does allow addition of a new Map.Entry(s) via the Set.add(Object) or Set.addAll(java.util.Collection) methods.

        Iterator Use

        This class implements the CloseableIteratorSet interface which creates a CloseableIterator instead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.
        Specified by:
        entrySet in interface Cache<K,​V>
        Specified by:
        entrySet in interface Map<K,​V>
        Overrides:
        entrySet in class AbstractDelegatingCache<K,​V>
        Returns:
        a set view of the mappings contained in this cache and cache loader across the entire cluster.
      • values

        public CacheCollection<V> values()
        Description copied from interface: Cache
        Returns a collection view of the values contained in this cache across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing collection is just returned. Invocation on the collection itself is when the various operations are ran.

        Care should be taken when invoking Collection.toArray(), Collection.toArray(Object[]), Collection.size(), Collection.retainAll(Collection) and Collection.iterator() methods as they will traverse the entire contents of the cluster including a configured CacheLoader and remote entries. The former 2 methods especially have a very high likely hood of causing a OutOfMemoryError due to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operations

        *

        Supported Flags

        Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets.

        If there are performance concerns then the Flag.SKIP_CACHE_LOAD flag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to prevent OutOfMemoryError)

        Also if you want the local contents only you can use the Flag.CACHE_MODE_LOCAL flag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentioned Flag.SKIP_CACHE_LOAD is also configured.

        Iterator Use

        This class implements the CloseableIteratorCollection interface which creates a CloseableIterator instead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.

        The iterator retrieved using CloseableIteratorCollection.iterator() supports the remove method, however the iterator retrieved from CacheStream.iterator() will not support remove.

        Unsupported Operations

        Due to not being able to add null values the following methods are not supported and will throw UnsupportedOperationException if invoked. Set.add(Object) Set.addAll(java.util.Collection)
        Specified by:
        values in interface Cache<K,​V>
        Specified by:
        values in interface Map<K,​V>
        Overrides:
        values in class AbstractDelegatingCache<K,​V>
        Returns:
        a collection view of the values contained in this cache and cache loader across the entire cluster.
      • getAsync

        public CompletableFuture<V> getAsync​(K key)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of Map.get(Object) that allows user code to retrieve the value associated with a key at a later stage, hence allowing multiple parallel get requests to be sent. Normally, when this method detects that the value is likely to be retrieved from from a remote entity, it will span a different thread in order to allow the asynchronous get call to return immediately. If the call will definitely resolve locally, for example when the cache is configured with LOCAL mode and no stores are configured, the get asynchronous call will act sequentially and will have no different to Map.get(Object).
        Specified by:
        getAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        Overrides:
        getAsync in class AbstractDelegatingCache<K,​V>
        Parameters:
        key - key to retrieve
        Returns:
        a future that can be used to retrieve value associated with the key when this is available. The actual value returned by the future follows the same rules as Map.get(Object)
      • addListener

        public void addListener​(Object listener)
        Description copied from interface: Listenable
        Adds a listener to the component. Typically, listeners would need to be annotated with Listener and further to that, contain methods annotated appropriately, otherwise the listener will not be registered.

        See the Listener annotation for more information.

        Specified by:
        addListener in interface Listenable
        Overrides:
        addListener in class AbstractDelegatingCache<K,​V>
        Parameters:
        listener - must not be null.
      • addListener

        public <C> void addListener​(Object listener,
                                    CacheEventFilter<? super K,​? super V> filter,
                                    CacheEventConverter<? super K,​? super V,​C> converter)
        Description copied from interface: FilteringListenable
        Registers a listener that will be notified on events that pass the filter condition. The value presented in the notifications will be first converted using the provided converter if there is one.

        Some implementations may provide optimizations when a CacheEventFilterConverter is provided as both arguments to the filter and converter arguments. Note the provided object must have reference equality ie. (==) to be recognized. This allows for the filter and conversion step to take place in the same method call reducing possible overhead.

        Specified by:
        addListener in interface FilteringListenable<K,​V>
        Overrides:
        addListener in class AbstractDelegatingCache<K,​V>
        Type Parameters:
        C - The type of the resultant value after being converted
        Parameters:
        listener - The listener to callback upon event notifications. Must not be null.
        filter - The filter to see if the notification should be sent to the listener. Can be null.
        converter - The converter to apply to the entry before being sent to the listener. Can be null.
      • addFilteredListener

        public <C> void addFilteredListener​(Object listener,
                                            CacheEventFilter<? super K,​? super V> filter,
                                            CacheEventConverter<? super K,​? super V,​C> converter,
                                            Set<Class<? extends Annotation>> filterAnnotations)
        Description copied from interface: FilteringListenable
        Registers a listener limiting the cache-entry specific events only to annotations that are passed in as parameter.

        For example, if the listener passed in contains callbacks for CacheEntryCreated and CacheEntryModified, and filtered annotations contains only CacheEntryCreated, then the listener will be registered only for CacheEntryCreated callbacks.

        Callback filtering only applies to CacheEntryCreated, CacheEntryModified, CacheEntryRemoved and CacheEntryExpired annotations. If the listener contains other annotations, these are preserved.

        This methods enables dynamic registration of listener interests at runtime without the need to create several different listener classes.

        Specified by:
        addFilteredListener in interface FilteringListenable<K,​V>
        Overrides:
        addFilteredListener in class AbstractDelegatingCache<K,​V>
        Type Parameters:
        C - The type of the resultant value after being converted
        Parameters:
        listener - The listener to callback upon event notifications. Must not be null.
        filter - The filter to see if the notification should be sent to the listener. Can be null.
        converter - The converter to apply to the entry before being sent to the listener. Can be null.
        filterAnnotations - cache-entry annotations to allow listener to be registered on. Must not be null.