Class SimpleCacheImpl<K,V>

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

@MBean(objectName="Cache", description="Component that represents a simplified cache instance.") public class SimpleCacheImpl<K,V> extends Object implements AdvancedCache<K,V>
Simple local cache without interceptor stack. The cache still implements AdvancedCache since it is too troublesome to omit that.
Author:
Radim Vansa <rvansa@redhat.com>
  • Constructor Details

    • SimpleCacheImpl

      public SimpleCacheImpl(String cacheName)
  • Method Details

    • 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
    • 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
    • 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>
      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
    • putForExternalReadInternal

      protected void putForExternalReadInternal(K key, V value, Metadata metadata, ByRef.Boolean isCreatedRef)
    • putAsync

      public CompletableFuture<V> putAsync(K key, V value, Metadata metadata)
      Description copied from interface: AdvancedCache
      Asynchronous version of AdvancedCache.put(Object, Object, Metadata) which stores metadata alongside the value. This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit over AdvancedCache.put(Object, Object, Metadata) if used in LOCAL mode.

      Specified by:
      putAsync in interface AdvancedCache<K,V>
      Parameters:
      key - key to use
      value - value to store
      metadata - information to store alongside the new value
      Returns:
      a future containing the old value replaced.
    • putAsyncEntry

      public CompletableFuture<CacheEntry<K,V>> putAsyncEntry(K key, V value, Metadata metadata)
      Description copied from interface: AdvancedCache
      Extension of AdvancedCache.putAsync(K, V, Metadata) which returns a CacheEntry instead of only the previous value.
      Specified by:
      putAsyncEntry in interface AdvancedCache<K,V>
      Parameters:
      key - key to use
      value - value to store
      metadata - information to store alongside the new value
      Returns:
      a future containing the old CacheEntry replaced.
    • 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>
      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.
    • 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>
    • getCacheEntry

      public CacheEntry<K,V> getCacheEntry(Object k)
      Description copied from interface: AdvancedCache
      Retrieves a CacheEntry corresponding to a specific key.
      Specified by:
      getCacheEntry in interface AdvancedCache<K,V>
      Parameters:
      k - the key whose associated cache entry is to be returned
      Returns:
      the cache entry to which the specified key is mapped, or null if this map contains no mapping for the key
    • getCacheEntryAsync

      public CompletableFuture<CacheEntry<K,V>> getCacheEntryAsync(Object key)
      Description copied from interface: AdvancedCache
      Retrieves a CacheEntry corresponding to a specific key.
      Specified by:
      getCacheEntryAsync in interface AdvancedCache<K,V>
      Parameters:
      key - the key whose associated cache entry is to be returned
      Returns:
      a future with the cache entry to which the specified key is mapped, or with null if this map contains no mapping for the key
    • 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>
      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.
    • computeAsync

      public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
      Description copied from interface: AdvancedCache
      Overloaded #computeAsync(K, BiFunction), which stores metadata alongside the value. This method does not block on remote calls, even if your cache mode is synchronous.
      Specified by:
      computeAsync in interface AdvancedCache<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.
    • computeIfPresentAsync

      public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
      Description copied from interface: AdvancedCache
      Overloaded #computeIfPresentAsync(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:
      computeIfPresentAsync in interface AdvancedCache<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.
    • computeIfAbsentAsync

      public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)
      Description copied from interface: AdvancedCache
      Overloaded #computeIfAbsentAsync(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:
      computeIfAbsentAsync in interface AdvancedCache<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.
    • 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 maxIdleTime, TimeUnit maxIdleTimeUnit)
      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>
    • mergeAsync

      public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)
      Description copied from interface: AdvancedCache
      Overloaded AsyncCache.mergeAsync(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:
      mergeAsync in interface AdvancedCache<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
    • 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>
    • 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>
      Parameters:
      groupName - the group name.
      Returns:
      an immutable Map with the key/value pairs.
    • removeGroup

      public void removeGroup(String groupName)
      Description copied from interface: AdvancedCache
      It removes all the key which belongs to a group.

      Semantically, it fetches the most recent group keys/values and removes them.

      Note that, concurrent addition perform by other transactions/threads to the group may not be removed.

      Specified by:
      removeGroup in interface AdvancedCache<K,V>
      Parameters:
      groupName - the group name.
    • getAvailability

      public AvailabilityMode getAvailability()
      Description copied from interface: AdvancedCache
      Returns the cache's availability. In local mode this method will always return AvailabilityMode.AVAILABLE. In clustered mode, the PartitionHandlingManager is queried to obtain the availability mode.
      Specified by:
      getAvailability in interface AdvancedCache<K,V>
    • setAvailability

      public void setAvailability(AvailabilityMode availabilityMode)
      Description copied from interface: AdvancedCache
      Manually change the availability of the cache. Doesn't change anything if the cache is not clustered or PartitionHandlingConfiguration.whenSplit() is set to PartitionHandling.ALLOW_READ_WRITES.
      Specified by:
      setAvailability in interface AdvancedCache<K,V>
    • touch

      public CompletionStage<Boolean> touch(Object key, boolean touchEvenIfExpired)
      Description copied from interface: AdvancedCache
      Touches the given key if present. This will refresh its last access time, used for max idle, and count as a recent access for eviction purposes.

      Note that it is possible to touch an entry that is expired via max idle if touchEvenIfExpired argument is true.

      This method will return without blocking and complete the returned stage with a value after all appropriate nodes have actually touched the value.

      Specified by:
      touch in interface AdvancedCache<K,V>
      Parameters:
      key - key of the entry to touch
      touchEvenIfExpired - true if the entry should be touched even if already expired via max idle, effectively making it so the entry is no longer expired via max idle
      Returns:
      true if the entry was actually touched
    • touch

      public CompletionStage<Boolean> touch(Object key, int segment, boolean touchEvenIfExpired)
      Description copied from interface: AdvancedCache
      The same as AdvancedCache.touch(Object, boolean) except that the segment is already known. This can be helpful to reduce an extra segment computation
      Specified by:
      touch in interface AdvancedCache<K,V>
      Parameters:
      key - key of the entry to touch
      segment - segment of the key
      touchEvenIfExpired - true if the entry should be touched even if already expired via max idle, effectively making it so the entry is no longer expired via max idle
      Returns:
      true if the entry was actually touched
    • 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>
    • 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
    • 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()
    • checkExpiration

      protected boolean checkExpiration(InternalCacheEntry<K,V> entry, long now)
    • 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>
    • get

      public V get(Object key)
      Specified by:
      get 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.
    • 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.
    • 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.
    • cacheEntrySet

      public CacheSet<CacheEntry<K,V>> cacheEntrySet()
      Description copied from interface: AdvancedCache
      Identical to Cache.entrySet() but is typed to return CacheEntries instead of Entries. Please see the other method for a description of its behaviors.

      This method is needed since nested generics do not support covariance

      Specified by:
      cacheEntrySet in interface AdvancedCache<K,V>
      Returns:
      the entry set containing all of the CacheEntries
      See Also:
    • lockedStream

      public LockedStream<K,V> lockedStream()
      Description copied from interface: AdvancedCache
      Returns a sequential stream using this Cache as the source. This stream is very similar to using the CacheStream returned from the CacheCollection.stream() method of the collection returned via AdvancedCache.cacheEntrySet(). The use of this locked stream is that when an entry is being processed by the user the entry is locked for the invocation preventing a different thread from modifying it.

      Note that this stream is not supported when using a optimistic transactional or simple cache. Both non transactional and pessimistic transactional caches are supported.

      The stream will not share any ongoing transaction the user may have. Code executed by the stream should be treated as completely independent. That is any operation performed via the stream will require the user to start their own transaction or will be done intrinsically on the invocation. Note that if there is an ongoing transaction that has a lock on a key from the cache, that it will cause a deadlock.

      Currently simple cache, ConfigurationBuilder.simpleCache(boolean) was set to true, and optimistic caches, TransactionConfigurationBuilder.lockingMode(LockingMode) was set to LockingMode.OPTIMISTIC, do not support this method. In this case it will throw an UnsupportedOperationException. This restriction may be removed in a future version. Also this method cannot be used on a cache that has a lock owner already specified via AdvancedCache.lockAs(Object) as this could lead to a deadlock or the release of locks early and will throw an IllegalStateException.

      Specified by:
      lockedStream in interface AdvancedCache<K,V>
      Returns:
      the locked stream
    • 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>
      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>
      Parameters:
      key - the key that expired via max idle for the given entry
      Returns:
      if the entry was removed
    • withEncoding

      public AdvancedCache<?,?> withEncoding(Class<? extends Encoder> encoder)
      Description copied from interface: AdvancedCache
      Performs any cache operations using the specified Encoder.
      Specified by:
      withEncoding in interface AdvancedCache<K,V>
      Parameters:
      encoder - Encoder used for both keys and values.
      Returns:
      an instance of AdvancedCache where all operations will use the supplied encoder.
    • withEncoding

      public AdvancedCache<?,?> withEncoding(Class<? extends Encoder> keyEncoder, Class<? extends Encoder> valueEncoder)
      Description copied from interface: AdvancedCache
      Performs any cache operations using the specified pair of Encoder.
      Specified by:
      withEncoding in interface AdvancedCache<K,V>
      Parameters:
      keyEncoder - Encoder for the keys.
      valueEncoder - Encoder for the values.
      Returns:
      an instance of AdvancedCache where all operations will use the supplied encoders.
    • withKeyEncoding

      public AdvancedCache<Object,Object> withKeyEncoding(Class<? extends Encoder> encoder)
      Specified by:
      withKeyEncoding in interface AdvancedCache<K,V>
    • withWrapping

      public AdvancedCache<K,V> withWrapping(Class<? extends Wrapper> wrapper)
      Description copied from interface: AdvancedCache
      Performs any cache operations using the specified Wrapper.
      Specified by:
      withWrapping in interface AdvancedCache<K,V>
      Parameters:
      wrapper - Wrapper for the keys and values.
      Returns:
      an instance of AdvancedCache where all operations will use the supplied wrapper.
    • withMediaType

      public AdvancedCache<?,?> withMediaType(String keyMediaType, String valueMediaType)
      Description copied from interface: AdvancedCache
      Perform any cache operations using an alternate MediaType.
      Specified by:
      withMediaType in interface AdvancedCache<K,V>
      Parameters:
      keyMediaType - MediaType for the keys.
      valueMediaType - org.infinispan.commons.dataconversion for the values.
      Returns:
      an instance of AdvancedCache where all data will formatted according to the supplied MediaType.
    • withMediaType

      public <K1, V1> AdvancedCache<K1,V1> withMediaType(MediaType keyMediaType, MediaType valueMediaType)
      Specified by:
      withMediaType in interface AdvancedCache<K,V>
      See Also:
    • withStorageMediaType

      public AdvancedCache<K,V> withStorageMediaType()
      Description copied from interface: AdvancedCache
      Perform any cache operations using the same MediaType of the cache storage. This is equivalent to disabling transcoding on the cache.
      Specified by:
      withStorageMediaType in interface AdvancedCache<K,V>
      Returns:
      an instance of AdvancedCache where no data conversion will take place.
    • withWrapping

      public AdvancedCache<K,V> withWrapping(Class<? extends Wrapper> keyWrapper, Class<? extends Wrapper> valueWrapper)
      Description copied from interface: AdvancedCache
      Performs any cache operations using the specified pair of Wrapper.
      Specified by:
      withWrapping in interface AdvancedCache<K,V>
      Parameters:
      keyWrapper - Wrapper for the keys.
      valueWrapper - Wrapper for the values.
      Returns:
      AdvancedCache where all operations will use the supplied wrappers.
    • getKeyDataConversion

      public DataConversion getKeyDataConversion()
      Specified by:
      getKeyDataConversion in interface AdvancedCache<K,V>
      Returns:
      The associated DataConversion for the keys.
    • getValueDataConversion

      public DataConversion getValueDataConversion()
      Specified by:
      getValueDataConversion in interface AdvancedCache<K,V>
      Returns:
      The associated DataConversion for the cache's values.
    • 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>
    • 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
    • getConfigurationAsProperties

      @ManagedAttribute(description="Returns the cache configuration in form of properties", displayName="Cache configuration properties", dataType=TRAIT) public Properties getConfigurationAsProperties()
    • 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>
    • 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.
    • getAndPutInternal

      protected V getAndPutInternal(K key, V value, Metadata metadata)
    • 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.
    • 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>
      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.
    • putIfAbsentInternal

      protected V putIfAbsentInternal(K key, V value, Metadata metadata)
    • 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
    • getAndReplaceInternal

      protected V getAndReplaceInternal(K key, V value, Metadata metadata)
    • 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
    • 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>
      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
    • replaceInternal

      protected boolean replaceInternal(K key, V oldValue, V value, Metadata metadata)
    • 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> map)
      Specified by:
      putAll 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
    • putAllAsync

      public CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> map, Metadata metadata)
      Specified by:
      putAllAsync in interface AdvancedCache<K,V>
    • 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
    • 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>
      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.
    • putIfAbsentAsyncEntry

      public CompletableFuture<CacheEntry<K,V>> putIfAbsentAsyncEntry(K key, V value, Metadata metadata)
      Description copied from interface: AdvancedCache
      An extension form of AdvancedCache.putIfAbsentAsync(K, V, Metadata), which returns a CacheEntry instead of only the value.
      Specified by:
      putIfAbsentAsyncEntry in interface AdvancedCache<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 future that contains previous CacheEntry associated with the specified key, or null if there was no mapping for the key.
      See Also:
    • 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
    • removeAsyncEntry

      public CompletableFuture<CacheEntry<K,V>> removeAsyncEntry(Object key)
      Description copied from interface: AdvancedCache
      An extension of AsyncCache.removeAsync(Object), which returns a CacheEntry instead of only the value.
      Specified by:
      removeAsyncEntry in interface AdvancedCache<K,V>
      Parameters:
      key - key to remove
      Returns:
      a future containing the CacheEntry removed or null if not found.
      See Also:
    • 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
    • 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>
      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.
    • replaceAsyncEntry

      public CompletableFuture<CacheEntry<K,V>> replaceAsyncEntry(K key, V value, Metadata metadata)
      Description copied from interface: AdvancedCache
      An extension of AdvancedCache.replaceAsync(K, V, Metadata), which returns a CacheEntry instead of only the value.
      Specified by:
      replaceAsyncEntry in interface AdvancedCache<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 CacheEntry associated with the specified key, or null if there was no mapping for the key.
      See Also:
    • replaceAsync

      public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, Metadata metadata)
      Specified by:
      replaceAsync in interface AdvancedCache<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)
    • 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.
    • 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>
    • 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
    • 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
    • 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.
    • 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>
    • 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>
    • withFlags

      public AdvancedCache<K,V> withFlags(Flag... flags)
      Description copied from interface: AdvancedCache
      A method that adds flags to any API call. For example, consider the following code snippet:
         cache.withFlags(Flag.FORCE_WRITE_LOCK).get(key);
       
      will invoke a cache.get() with a write lock forced.

      Note that for the flag to take effect, the cache operation must be invoked on the instance returned by this method.

      As an alternative to setting this on every invocation, users should also consider saving the decorated cache, as this allows for more readable code. E.g.:

          AdvancedCache<?, ?> forceWriteLockCache = cache.withFlags(Flag.FORCE_WRITE_LOCK);
          forceWriteLockCache.get(key1);
          forceWriteLockCache.get(key2);
          forceWriteLockCache.get(key3);
       
      Specified by:
      withFlags in interface AdvancedCache<K,V>
      Parameters:
      flags - a set of flags to apply. See the Flag documentation.
      Returns:
      an AdvancedCache instance on which a real operation is to be invoked, if the flags are to be applied.
    • withFlags

      public AdvancedCache<K,V> withFlags(Collection<Flag> flags)
      Description copied from interface: AdvancedCache
      An alternative to AdvancedCache.withFlags(Flag...) not requiring array allocation.
      Specified by:
      withFlags in interface AdvancedCache<K,V>
    • noFlags

      public AdvancedCache<K,V> noFlags()
      Description copied from interface: AdvancedCache
      Unset all flags set on this cache using AdvancedCache.withFlags(Flag...) or AdvancedCache.withFlags(Collection) methods.
      Specified by:
      noFlags in interface AdvancedCache<K,V>
      Returns:
      Cache not applying any flags to the command; possibly this.
    • transform

      public AdvancedCache<K,V> transform(Function<AdvancedCache<K,V>,? extends AdvancedCache<K,V>> transformation)
      Description copied from interface: AdvancedCache
      Apply the transformation on each AdvancedCache instance in a delegation chain, starting with the innermost implementation.
      Specified by:
      transform in interface AdvancedCache<K,V>
      Returns:
      The outermost transformed cache.
    • withSubject

      public AdvancedCache<K,V> withSubject(Subject subject)
      Description copied from interface: AdvancedCache
      Performs any cache operations using the specified Subject. Only applies to caches with authorization enabled (see ConfigurationBuilder.security()).
      Specified by:
      withSubject in interface AdvancedCache<K,V>
      Returns:
      an AdvancedCache instance on which a real operation is to be invoked, using the specified subject
    • getAsyncInterceptorChain

      @Deprecated(forRemoval=true) public AsyncInterceptorChain getAsyncInterceptorChain()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Since 10.0, will be removed without a replacement
      Description copied from interface: AdvancedCache
      Allows the modification of the interceptor chain.
      Specified by:
      getAsyncInterceptorChain in interface AdvancedCache<K,V>
    • getEvictionManager

      public EvictionManager getEvictionManager()
      Specified by:
      getEvictionManager in interface AdvancedCache<K,V>
      Returns:
      the eviction manager - if one is configured - for this cache instance
    • getExpirationManager

      public ExpirationManager<K,V> getExpirationManager()
      Specified by:
      getExpirationManager in interface AdvancedCache<K,V>
      Returns:
      the expiration manager - if one is configured - for this cache instance
    • getComponentRegistry

      public ComponentRegistry getComponentRegistry()
      Specified by:
      getComponentRegistry in interface AdvancedCache<K,V>
      Returns:
      the component registry for this cache instance
    • getDistributionManager

      public DistributionManager getDistributionManager()
      Description copied from interface: AdvancedCache
      Retrieves a reference to the DistributionManager if the cache is configured to use Distribution. Otherwise, returns a null.
      Specified by:
      getDistributionManager in interface AdvancedCache<K,V>
      Returns:
      a DistributionManager, or null.
    • getAuthorizationManager

      public AuthorizationManager getAuthorizationManager()
      Description copied from interface: AdvancedCache
      Retrieves the AuthorizationManager if the cache has security enabled. Otherwise returns null
      Specified by:
      getAuthorizationManager in interface AdvancedCache<K,V>
      Returns:
      an AuthorizationManager or null
    • lockAs

      public AdvancedCache<K,V> lockAs(Object lockOwner)
      Description copied from interface: AdvancedCache
      Whenever this cache acquires a lock it will do so using the given Object as the owner of said lock.

      This can be useful when a lock may have been manually acquired and you wish to reuse that lock across invocations.

      Great care should be taken with this command as misuse can very easily lead to deadlocks.

      Specified by:
      lockAs in interface AdvancedCache<K,V>
      Parameters:
      lockOwner - the lock owner to lock any keys as
      Returns:
      an AdvancedCache instance on which when an operation is invoked it will use lock owner object to acquire any locks
    • 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>
      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>
      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.
    • getRpcManager

      public RpcManager getRpcManager()
      Description copied from interface: AdvancedCache
      Returns the component in charge of communication with other caches in the cluster. If the cache's ClusteringConfiguration.cacheMode() is CacheMode.LOCAL, this method will return null.
      Specified by:
      getRpcManager in interface AdvancedCache<K,V>
      Returns:
      the RPC manager component associated with this cache instance or null
    • getBatchContainer

      public BatchContainer getBatchContainer()
      Description copied from interface: AdvancedCache
      Returns the component in charge of batching cache operations.
      Specified by:
      getBatchContainer in interface AdvancedCache<K,V>
      Returns:
      the batching component associated with this cache instance
    • getDataContainer

      public DataContainer<K,V> getDataContainer()
      Description copied from interface: AdvancedCache
      Returns the container where data is stored in the cache. Users should interact with this component with care because direct calls on it bypass the internal interceptors and other infrastructure in place to guarantee the consistency of data.
      Specified by:
      getDataContainer in interface AdvancedCache<K,V>
      Returns:
      the data container associated with this cache instance
    • getTransactionManager

      public javax.transaction.TransactionManager getTransactionManager()
      Specified by:
      getTransactionManager in interface TransactionalCache
      Returns:
      the TransactionManager in use by this cache or null if the cache isn't transactional.
    • getLockManager

      public LockManager getLockManager()
      Description copied from interface: AdvancedCache
      Returns the component that deals with all aspects of acquiring and releasing locks for cache entries.
      Specified by:
      getLockManager in interface AdvancedCache<K,V>
      Returns:
      retrieves the lock manager associated with this cache instance
    • getStats

      public Stats getStats()
      Description copied from interface: AdvancedCache
      Returns a Stats object that allows several statistics associated with this cache at runtime.
      Specified by:
      getStats in interface AdvancedCache<K,V>
      Returns:
      this cache's Stats object
    • getXAResource

      public XAResource getXAResource()
      Description copied from interface: AdvancedCache
      Returns the XAResource associated with this cache which can be used to do transactional recovery.
      Specified by:
      getXAResource in interface AdvancedCache<K,V>
      Returns:
      an instance of XAResource
    • getClassLoader

      public ClassLoader getClassLoader()
      Description copied from interface: AdvancedCache
      Returns the cache loader associated associated with this cache. As an alternative to setting this on every invocation, users could also consider using the DecoratedCache wrapper.
      Specified by:
      getClassLoader in interface AdvancedCache<K,V>
      Returns:
      this cache's cache loader
    • with

      public AdvancedCache<K,V> with(ClassLoader classLoader)
      Specified by:
      with in interface AdvancedCache<K,V>
    • 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>
      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.
    • 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>
      Parameters:
      map - the values to store
      metadata - information to store alongside the value(s)
    • putAllInternal

      protected void putAllInternal(Map<? extends K,? extends V> map, Metadata metadata)
    • 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>
      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.
    • 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, 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>
      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: 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
    • computeIfAbsentInternal

      protected V computeIfAbsentInternal(K key, Function<? super K,? extends V> mappingFunction, ByRef<V> newValueRef)
    • 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
    • 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>
      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.
    • computeIfPresentInternal

      protected V computeIfPresentInternal(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, SimpleCacheImpl.CacheEntryChange<K,V> ref)
    • 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
    • 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>
      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.
    • computeInternal

      protected V computeInternal(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, SimpleCacheImpl.CacheEntryChange<K,V> ref)
    • 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
    • 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>
      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
    • mergeInternal

      protected V mergeInternal(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, SimpleCacheImpl.CacheEntryChange<K,V> ref, Metadata metadata)
    • 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>
    • 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>
    • getStreamSupplier

      protected Supplier<Stream<CacheEntry<K,V>>> getStreamSupplier(boolean parallel)
    • toString

      public String toString()
      Overrides:
      toString in class Object