Class AbstractDelegatingCache<K,V>

java.lang.Object
org.infinispan.cache.impl.AbstractDelegatingCache<K,V>
All Implemented Interfaces:
ConcurrentMap<K,V>, Map<K,V>, Cache<K,V>, AsyncCache<K,V>, BasicCache<K,V>, BatchingCache, Lifecycle, FilteringListenable<K,V>, Listenable
Direct Known Subclasses:
AbstractDelegatingAdvancedCache

@MBean(objectName="Cache", description="Component that represents an individual cache instance.") public abstract class AbstractDelegatingCache<K,V> extends Object implements Cache<K,V>
This is a convenient base class for implementing a cache delegate. The only constructor takes a Cache argument, to which each method call is delegated. One can extend this class and override the method sub-set it is interested in. There is also an similar implementation for AdvancedCache: AbstractDelegatingAdvancedCache.
Author:
Mircea.Markus@jboss.com
See Also:
  • Field Details

    • cache

      protected final Cache<K,V> cache
  • Constructor Details

    • AbstractDelegatingCache

      public AbstractDelegatingCache(Cache<K,V> cache)
  • Method Details

    • 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>
      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 Cache.putForExternalRead(K, V), which takes in lifespan parameters.
      Specified by:
      putForExternalRead in interface Cache<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 Cache.putForExternalRead(K, V), which takes in lifespan parameters.
      Specified by:
      putForExternalRead in interface Cache<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>
      Parameters:
      key - key to evict
    • getCacheConfiguration

      public Configuration getCacheConfiguration()
      Specified by:
      getCacheConfiguration in interface Cache<K,V>
    • startBatch

      public boolean startBatch()
      Description copied from interface: BatchingCache
      Starts a batch. All operations on the current client thread are performed as a part of this batch, with locks held for the duration of the batch and any remote calls delayed till the end of the batch.

      Specified by:
      startBatch in interface BatchingCache
      Returns:
      true if a batch was successfully started; false if one was available and already running.
    • endBatch

      public void endBatch(boolean successful)
      Description copied from interface: BatchingCache
      Completes a batch if one has been started using BatchingCache.startBatch(). If no batch has been started, this is a no-op.

      Specified by:
      endBatch in interface BatchingCache
      Parameters:
      successful - if true, the batch completes, otherwise the batch is aborted and changes are not committed.
    • getName

      public String getName()
      Description copied from interface: BasicCache
      Retrieves the name of the cache
      Specified by:
      getName in interface BasicCache<K,V>
      Returns:
      the name of the cache
    • getCacheName

      @ManagedAttribute(description="Returns the cache name", displayName="Cache name", dataType=TRAIT) public String getCacheName()
    • getVersion

      @ManagedAttribute(description="Returns the version of Infinispan", displayName="Infinispan version", dataType=TRAIT) public String getVersion()
      Description copied from interface: BasicCache
      Retrieves the version of Infinispan
      Specified by:
      getVersion in interface BasicCache<K,V>
      Returns:
      a version string
    • getCacheManager

      public EmbeddedCacheManager getCacheManager()
      Description copied from interface: Cache
      Retrieves the cache manager responsible for creating this cache instance.
      Specified by:
      getCacheManager in interface Cache<K,V>
      Returns:
      a cache manager
    • put

      public V put(K key, V value, long lifespan, TimeUnit unit)
      Description copied from interface: BasicCache
      An overloaded form of BasicCache.put(Object, Object), which takes in lifespan parameters.
      Specified by:
      put in interface BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.
      Specified by:
      putIfAbsent in interface BasicCache<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: 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 BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
      Specified by:
      replace in interface BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.
      Specified by:
      replace in interface BasicCache<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: BasicCache
      An overloaded form of BasicCache.put(Object, Object), which takes in lifespan parameters.
      Specified by:
      put in interface BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.
      Specified by:
      putIfAbsent in interface BasicCache<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: 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 BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
      Specified by:
      replace in interface BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.
      Specified by:
      replace in interface BasicCache<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
    • replaceAll

      public void replaceAll(BiFunction<? super K,? super V,? extends V> function)
      Specified by:
      replaceAll in interface ConcurrentMap<K,V>
      Specified by:
      replaceAll in interface Map<K,V>
    • putAsync

      public CompletableFuture<V> putAsync(K key, V value)
      Description copied from interface: 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 AsyncCache<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: 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 AsyncCache<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: 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 AsyncCache<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: 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 AsyncCache<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: 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 AsyncCache<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: 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 AsyncCache<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
    • clearAsync

      public CompletableFuture<Void> clearAsync()
      Description copied from interface: AsyncCache
      Asynchronous version of Map.clear(). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      clearAsync in interface AsyncCache<K,V>
      Returns:
      a future containing a void return type
    • putIfAbsentAsync

      public CompletableFuture<V> putIfAbsentAsync(K key, V value)
      Description copied from interface: 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 AsyncCache<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: 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 AsyncCache<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
    • putIfAbsentAsync

      public CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Description copied from interface: 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 AsyncCache<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
    • removeAsync

      public CompletableFuture<V> removeAsync(Object key)
      Description copied from interface: 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 AsyncCache<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: 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 AsyncCache<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: 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 AsyncCache<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: 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 AsyncCache<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, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Description copied from interface: 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 AsyncCache<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
    • replaceAsync

      public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
      Description copied from interface: 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 AsyncCache<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: 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 AsyncCache<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
    • replaceAsync

      public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Description copied from interface: 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 AsyncCache<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
    • computeAsync

      public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
      Description copied from interface: AsyncCache
      Asynchronous version of ConcurrentMap.compute(Object, BiFunction). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeAsync in interface AsyncCache<K,V>
    • computeAsync

      public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
      Description copied from interface: AsyncCache
      Asynchronous version of BasicCache.compute(Object, BiFunction, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeAsync in interface AsyncCache<K,V>
    • computeAsync

      public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Description copied from interface: AsyncCache
      Asynchronous version of BasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeAsync in interface AsyncCache<K,V>
    • computeIfAbsentAsync

      public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction)
      Description copied from interface: AsyncCache
      Asynchronous version of ConcurrentMap.computeIfAbsent(Object, Function). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeIfAbsentAsync in interface AsyncCache<K,V>
    • computeIfAbsentAsync

      public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit)
      Description copied from interface: AsyncCache
      Asynchronous version of BasicCache.computeIfAbsent(Object, Function, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeIfAbsentAsync in interface AsyncCache<K,V>
    • computeIfAbsentAsync

      public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Description copied from interface: AsyncCache
      Asynchronous version of BasicCache.computeIfAbsent(Object, Function, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeIfAbsentAsync in interface AsyncCache<K,V>
    • computeIfPresentAsync

      public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
      Description copied from interface: AsyncCache
      Asynchronous version of ConcurrentMap.computeIfPresent(Object, BiFunction). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeIfPresentAsync in interface AsyncCache<K,V>
    • computeIfPresentAsync

      public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
      Description copied from interface: AsyncCache
      Asynchronous version of BasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit) . This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeIfPresentAsync in interface AsyncCache<K,V>
    • computeIfPresentAsync

      public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Description copied from interface: AsyncCache
      Asynchronous version of BasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit, long, TimeUnit) . This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeIfPresentAsync in interface AsyncCache<K,V>
    • mergeAsync

      public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
      Description copied from interface: AsyncCache
      Asynchronous version of ConcurrentMap.merge(Object, Object, BiFunction). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      mergeAsync in interface AsyncCache<K,V>
    • mergeAsync

      public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
      Description copied from interface: AsyncCache
      Asynchronous version of BasicCache.merge(Object, Object, BiFunction, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      mergeAsync in interface AsyncCache<K,V>
    • mergeAsync

      public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Description copied from interface: AsyncCache
      Asynchronous version of BasicCache.merge(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      mergeAsync in interface AsyncCache<K,V>
    • getAdvancedCache

      public AdvancedCache<K,V> getAdvancedCache()
      Specified by:
      getAdvancedCache in interface Cache<K,V>
    • getStatus

      public ComponentStatus getStatus()
      Specified by:
      getStatus in interface Cache<K,V>
    • getCacheStatus

      @ManagedAttribute(description="Returns the cache status", displayName="Cache status", dataType=TRAIT) public String getCacheStatus()
      Returns String representation of ComponentStatus enumeration in order to avoid class not found exceptions in JMX tools that don't have access to infinispan classes.
    • putIfAbsent

      public V putIfAbsent(K key, V value)
      Specified by:
      putIfAbsent in interface ConcurrentMap<K,V>
      Specified by:
      putIfAbsent in interface Map<K,V>
    • remove

      public boolean remove(Object key, Object value)
      Specified by:
      remove in interface ConcurrentMap<K,V>
      Specified by:
      remove in interface Map<K,V>
    • replace

      public boolean replace(K key, V oldValue, V newValue)
      Specified by:
      replace in interface ConcurrentMap<K,V>
      Specified by:
      replace in interface Map<K,V>
    • replace

      public V replace(K key, V value)
      Specified by:
      replace in interface ConcurrentMap<K,V>
      Specified by:
      replace in interface Map<K,V>
    • size

      public int size()
      Description copied from interface: Cache
      Returns a count of all elements in this cache and cache loader across the entire cluster.

      Only a subset of entries is held in memory at a time when using a loader or remote entries, to prevent possible memory issues, however the loading of said entries can still be vary slow.

      If there are performance concerns then the Flag.SKIP_CACHE_LOAD flag should be used to avoid hitting the cache loader in case if this is not needed in the size calculation.

      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.

      If this method is used in a transactional context, note this method will not bring additional values into the transaction context and thus objects that haven't yet been read will act in a IsolationLevel.READ_COMMITTED behavior irrespective of the configured isolation level. However values that have been previously modified or read that are in the context will be adhered to. e.g. any write modification or any previous read when using IsolationLevel.REPEATABLE_READ

      This method should only be used for debugging purposes such as to verify that the cache contains all the keys entered. Any other use involving execution of this method on a production system is not recommended.

      Specified by:
      size in interface Cache<K,V>
      Specified by:
      size in interface Map<K,V>
      Returns:
      the number of key-value mappings in this cache and cache loader across the entire cluster.
    • sizeAsync

      public CompletableFuture<Long> sizeAsync()
      Description copied from interface: AsyncCache
      Asynchronous version of Map.size(). This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      sizeAsync in interface AsyncCache<K,V>
      Returns:
      a future containing the count of the cache
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • 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>
    • compute

      public V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
      Description copied from interface: BasicCache
      An overloaded form of ConcurrentMap.compute(Object, BiFunction) which takes in lifespan parameters.
      Specified by:
      compute in interface BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.compute(Object, BiFunction) which takes in lifespan and maxIdleTime parameters.
      Specified by:
      compute in interface BasicCache<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>
    • computeIfPresent

      public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
      Description copied from interface: BasicCache
      An overloaded form of ConcurrentMap.computeIfPresent(Object, BiFunction) which takes in lifespan parameters.
      Specified by:
      computeIfPresent in interface BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.computeIfPresent(Object, BiFunction) which takes in lifespan and maxIdleTime parameters.
      Specified by:
      computeIfPresent in interface BasicCache<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>
    • computeIfAbsent

      public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit)
      Description copied from interface: BasicCache
      An overloaded form of ConcurrentMap.computeIfAbsent(Object, Function) which takes in lifespan parameters.
      Specified by:
      computeIfAbsent in interface BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.computeIfAbsent(Object, Function) which takes in lifespan and maxIdleTime parameters.
      Specified by:
      computeIfAbsent in interface BasicCache<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
    • get

      public V get(Object key)
      Specified by:
      get in interface Map<K,V>
    • getOrDefault

      public V getOrDefault(Object key, V defaultValue)
      Specified by:
      getOrDefault in interface ConcurrentMap<K,V>
      Specified by:
      getOrDefault in interface Map<K,V>
    • put

      public V put(K key, V value)
      Description copied from interface: 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 BasicCache<K,V>
      Specified by:
      put in interface Map<K,V>
    • remove

      public V remove(Object key)
      Description copied from interface: 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 BasicCache<K,V>
      Specified by:
      remove in interface Map<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends V> t)
      Specified by:
      putAll in interface Map<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>
    • merge

      public V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
      Description copied from interface: BasicCache
      An overloaded form of ConcurrentMap.merge(Object, Object, BiFunction) which takes in lifespan parameters.
      Specified by:
      merge in interface BasicCache<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: BasicCache
      An overloaded form of ConcurrentMap.merge(Object, Object, BiFunction) which takes in lifespan parameters.
      Specified by:
      merge in interface BasicCache<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
    • forEach

      public void forEach(BiConsumer<? super K,? super V> action)
      Specified by:
      forEach in interface ConcurrentMap<K,V>
      Specified by:
      forEach in interface Map<K,V>
    • clear

      @ManagedOperation(description="Clears the cache", displayName="Clears the cache", name="clear") public void clear()
      Description copied from interface: Cache
      Removes all mappings from the cache.

      Note: This should never be invoked in production unless you can guarantee no other invocations are ran concurrently.

      If the cache is transactional, it will not interact with the transaction.

      Specified by:
      clear in interface Cache<K,V>
      Specified by:
      clear in interface Map<K,V>
    • 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>
      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>
      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>
      Returns:
      a collection view of the values contained in this cache and cache loader across the entire cluster.
    • start

      @ManagedOperation(description="Starts the cache.", displayName="Starts cache.") public void start()
      Description copied from interface: Lifecycle
      Invoked on component start
      Specified by:
      start in interface Lifecycle
    • stop

      @ManagedOperation(description="Stops the cache.", displayName="Stops cache.") public void stop()
      Description copied from interface: Cache
      Stops a cache. If the cache is clustered, this only stops the cache on the node where it is being invoked. If you need to stop the cache across a cluster, use the Cache.shutdown() method.
      Specified by:
      stop in interface Cache<K,V>
      Specified by:
      stop in interface Lifecycle
    • shutdown

      @ManagedOperation(description="Shuts down the cache across the cluster", displayName="Clustered cache shutdown") public void shutdown()
      Description copied from interface: Cache
      Performs a controlled, clustered shutdown of the cache. When invoked, the following operations are performed: This method differs from Cache.stop() only in clustered modes, and only when GlobalStateConfiguration.enabled() is true, otherwise it just behaves like Cache.stop().
      Specified by:
      shutdown in interface Cache<K,V>
    • 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
      Parameters:
      listener - listener to add, must not be null
    • addListenerAsync

      public CompletionStage<Void> addListenerAsync(Object listener)
      Description copied from interface: Listenable
      Asynchronous version of Listenable.addListener(Object)
      Specified by:
      addListenerAsync in interface Listenable
      Parameters:
      listener - listener to add, must not be null
      Returns:
      CompletionStage that when complete the listener is fully installed
    • 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>
      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.
    • addListenerAsync

      public <C> CompletionStage<Void> addListenerAsync(Object listener, CacheEventFilter<? super K,? super V> filter, CacheEventConverter<? super K,? super V,C> converter)
      Description copied from interface: FilteringListenable
      Specified by:
      addListenerAsync in interface FilteringListenable<K,V>
      Parameters:
      listener - listener to add, must not be null
      Returns:
      CompletionStage that when complete the listener is fully installed
    • removeListener

      public void removeListener(Object listener)
      Description copied from interface: Listenable
      Removes a listener from the component.
      Specified by:
      removeListener in interface Listenable
      Parameters:
      listener - listener to remove. Must not be null.
    • removeListenerAsync

      public CompletionStage<Void> removeListenerAsync(Object listener)
      Description copied from interface: Listenable
      Asynchronous version of Listenable.removeListener(Object)
      Specified by:
      removeListenerAsync in interface Listenable
      Parameters:
      listener - listener to remove, must not be null
      Returns:
      CompletionStage that when complete the listener is fully removed
    • getListeners

      @Deprecated(forRemoval=true) public Set<Object> getListeners()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      getListeners in interface Listenable
      Returns:
      a set of all listeners registered on this component.
    • 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>
      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.
    • addFilteredListenerAsync

      public <C> CompletionStage<Void> addFilteredListenerAsync(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
      Specified by:
      addFilteredListenerAsync in interface FilteringListenable<K,V>
    • addStorageFormatFilteredListener

      public <C> void addStorageFormatFilteredListener(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
      Same as FilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set), but assumes the filter and/or the converter will be done in the same data format as it's stored in the cache.
      Specified by:
      addStorageFormatFilteredListener in interface FilteringListenable<K,V>
    • addStorageFormatFilteredListenerAsync

      public <C> CompletionStage<Void> addStorageFormatFilteredListenerAsync(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
      Specified by:
      addStorageFormatFilteredListenerAsync in interface FilteringListenable<K,V>
    • getAsync

      public CompletableFuture<V> getAsync(K key)
      Description copied from interface: 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 AsyncCache<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)
    • getAllAsync

      public CompletableFuture<Map<K,V>> getAllAsync(Set<?> keys)
      Description copied from interface: AsyncCache
      TODO This should be in AdvancedCache with getAll
      Specified by:
      getAllAsync in interface AsyncCache<K,V>
    • getConfigurationAsProperties

      @ManagedAttribute(description="Returns the cache configuration in form of properties", displayName="Cache configuration properties", dataType=TRAIT) public Properties getConfigurationAsProperties()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDelegate

      public Cache<K,V> getDelegate()
    • unwrapCache

      public static <K, V> Cache<K,V> unwrapCache(Cache<K,V> cache)
      Fully unwraps a given cache returning the base cache. Will unwrap all AbstractDelegatingCache wrappers.
      Type Parameters:
      K -
      V -
      Parameters:
      cache -
      Returns: