Class RemoteCacheSupport<K,V>

java.lang.Object
org.infinispan.client.hotrod.impl.RemoteCacheSupport<K,V>
All Implemented Interfaces:
ConcurrentMap<K,V>, Map<K,V>, RemoteCache<K,V>, AsyncCache<K,V>, BasicCache<K,V>, Lifecycle, TransactionalCache
Direct Known Subclasses:
DelegatingRemoteCache, RemoteCacheImpl

public abstract class RemoteCacheSupport<K,V> extends Object implements RemoteCache<K,V>
Purpose: keep all delegating and unsupported methods in one place -> readability.
Since:
4.1
Author:
Mircea.Markus@jboss.com
  • Field Details

    • defaultLifespan

      protected long defaultLifespan
    • defaultMaxIdleTime

      protected long defaultMaxIdleTime
  • Constructor Details

    • RemoteCacheSupport

      protected RemoteCacheSupport()
    • RemoteCacheSupport

      protected RemoteCacheSupport(long defaultLifespan, long defaultMaxIdleTime)
  • Method Details

    • putAll

      public final void putAll(Map<? extends K,? extends V> map)
      Description copied from interface: RemoteCache
      Adds or overrides each specified entry in the remote cache. This operation provides better performance than calling put() for each entry.
      Specified by:
      putAll in interface Map<K,V>
      Specified by:
      putAll in interface RemoteCache<K,V>
      See Also:
    • putAll

      public final void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
      Description copied from interface: RemoteCache
      Adds or overrides each specified entry in the remote cache. This operation provides better performance than calling put() for each entry.
      Specified by:
      putAll in interface BasicCache<K,V>
      Specified by:
      putAll in interface RemoteCache<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
    • putAll

      public final void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
      Description copied from interface: RemoteCache
      Adds or overrides each specified entry in the remote cache. This operation provides better performance than calling put() for each entry.
      Specified by:
      putAll in interface BasicCache<K,V>
      Specified by:
      putAll in interface RemoteCache<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
      See Also:
    • putAllAsync

      public final CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data)
      Description copied from interface: RemoteCache
      Adds or overrides each specified entry in the remote cache. This operation provides better performance than calling put() for each entry.
      Specified by:
      putAllAsync in interface AsyncCache<K,V>
      Specified by:
      putAllAsync in interface RemoteCache<K,V>
      Parameters:
      data - to store
      Returns:
      a future containing a void return type
      See Also:
    • putAllAsync

      public final CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)
      Description copied from interface: RemoteCache
      Adds or overrides each specified entry in the remote cache. This operation provides better performance than calling put() for each entry.
      Specified by:
      putAllAsync in interface AsyncCache<K,V>
      Specified by:
      putAllAsync in interface RemoteCache<K,V>
      Parameters:
      data - to store
      lifespan - lifespan of entry
      unit - time unit for lifespan
      Returns:
      a future containing a void return type
      See Also:
    • putAllAsync

      public abstract CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
      Description copied from interface: RemoteCache
      Adds or overrides each specified entry in the remote cache. This operation provides better performance than calling put() for each entry.
      Specified by:
      putAllAsync in interface AsyncCache<K,V>
      Specified by:
      putAllAsync in interface RemoteCache<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
      See Also:
    • putIfAbsent

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

      public final 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 final 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.
    • putIfAbsentAsync

      public final 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 final CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit)
      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
      lifespanUnit - time unit for lifespan
      Returns:
      a future containing the old value replaced
    • putIfAbsentAsync

      public abstract 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
    • replace

      public final boolean replace(K key, V oldValue, V newValue)
      Description copied from interface: RemoteCache

      This method requires 2 round trips to the server. The first to retrieve the value and version and a second to replace the key with the version if the value matches. If possible user should use RemoteCache.getWithMetadata(Object) and RemoteCache.replaceWithVersion(Object, Object, long).

      Specified by:
      replace in interface ConcurrentMap<K,V>
      Specified by:
      replace in interface Map<K,V>
      Specified by:
      replace in interface RemoteCache<K,V>
    • replace

      public final boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit unit)
      Description copied from interface: RemoteCache
      An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.

      This method requires 2 round trips to the server. The first to retrieve the value and version and a second to replace the key with the version if the value matches. If possible user should use RemoteCache.getWithMetadata(Object) and RemoteCache.replaceWithVersion(Object, Object, long, long, TimeUnit, long, TimeUnit).

      Specified by:
      replace in interface BasicCache<K,V>
      Specified by:
      replace in interface RemoteCache<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
    • replace

      public final boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
      Description copied from interface: RemoteCache
      An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.

      This method requires 2 round trips to the server. The first to retrieve the value and version and a second to replace the key with the version if the value matches. If possible user should use RemoteCache.getWithMetadata(Object) and RemoteCache.replaceWithVersion(Object, Object, long, long, TimeUnit, long, TimeUnit) if possible.

      Specified by:
      replace in interface BasicCache<K,V>
      Specified by:
      replace in interface RemoteCache<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
    • replaceAsync

      public final 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 final 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 abstract 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
    • replace

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

      public final 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 final 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.
    • replaceAsync

      public final 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 final 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 abstract 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
    • get

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

      public abstract 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)
    • getAll

      public final Map<K,V> getAll(Set<? extends K> keys)
      Description copied from interface: RemoteCache
      Retrieves all of the entries for the provided keys. A key will not be present in the resulting map if the entry was not found in the cache.
      Specified by:
      getAll in interface RemoteCache<K,V>
      Parameters:
      keys - The keys to find values for
      Returns:
      The entries that were present for the given keys
    • getAllAsync

      public abstract 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>
    • getWithMetadata

      public final MetadataValue<V> getWithMetadata(K key)
      Description copied from interface: RemoteCache
      Returns the MetadataValue associated to the supplied key param, or null if it doesn't exist.
      Specified by:
      getWithMetadata in interface RemoteCache<K,V>
    • getWithMetadataAsync

      public abstract CompletableFuture<MetadataValue<V>> getWithMetadataAsync(K key)
      Description copied from interface: RemoteCache
      Asynchronously returns the MetadataValue associated to the supplied key param, or null if it doesn't exist.
      Specified by:
      getWithMetadataAsync in interface RemoteCache<K,V>
    • containsKey

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

      public abstract CompletableFuture<Boolean> containsKeyAsync(K key)
      Description copied from interface: AsyncCache
      Asynchronous version of Map.containsKey(Object)
      Specified by:
      containsKeyAsync in interface AsyncCache<K,V>
      Parameters:
      key - key to retrieve
      Returns:
      future containing true if the mapping exists.
    • put

      public final 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 final 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.
    • put

      public final 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.
    • putAsync

      public final 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 final 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 abstract 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
    • replaceWithVersion

      public final boolean replaceWithVersion(K key, V newValue, long version)
      Description copied from interface: RemoteCache
      Replaces the given value only if its version matches the supplied version. See RemoteCache.removeWithVersion(Object, long) for a sample usage of the version-based methods.
      Specified by:
      replaceWithVersion in interface RemoteCache<K,V>
      version - numeric version that should match the one in the server for the operation to succeed
      Returns:
      true if the value has been replaced
      See Also:
    • replaceWithVersion

      public final boolean replaceWithVersion(K key, V newValue, long version, int lifespanSeconds)
      Description copied from interface: RemoteCache
      A overloaded form of RemoteCache.replaceWithVersion(Object, Object, long) which takes in lifespan parameters.
      Specified by:
      replaceWithVersion in interface RemoteCache<K,V>
      Parameters:
      key - key to use
      newValue - new value to be associated with the key
      version - numeric version that should match the one in the server for the operation to succeed
      lifespanSeconds - lifespan of the entry
      Returns:
      true if the value was replaced
    • replaceWithVersion

      public final boolean replaceWithVersion(K key, V newValue, long version, int lifespanSeconds, int maxIdleTimeSeconds)
      Description copied from interface: RemoteCache
      A overloaded form of RemoteCache.replaceWithVersion(Object, Object, long) which takes in lifespan and maximum idle time parameters.
      Specified by:
      replaceWithVersion in interface RemoteCache<K,V>
      Parameters:
      key - key to use
      newValue - new value to be associated with the key
      version - numeric version that should match the one in the server for the operation to succeed
      lifespanSeconds - lifespan of the entry
      maxIdleTimeSeconds - the maximum amount of time this key is allowed to be idle for before it is considered as expired
      Returns:
      true if the value was replaced
    • replaceWithVersion

      public final boolean replaceWithVersion(K key, V newValue, long version, long lifespan, TimeUnit lifespanTimeUnit, long maxIdle, TimeUnit maxIdleTimeUnit)
      Description copied from interface: RemoteCache
      A overloaded form of RemoteCache.replaceWithVersion(Object, Object, long) which takes in lifespan and maximum idle time parameters.
      Specified by:
      replaceWithVersion in interface RemoteCache<K,V>
      Parameters:
      key - key to use
      newValue - new value to be associated with the key
      version - numeric version that should match the one in the server for the operation to succeed
      lifespan - lifespan of the entry
      lifespanTimeUnit - TimeUnit for lifespan
      maxIdle - the maximum amount of time this key is allowed to be idle for before it is considered as expired
      maxIdleTimeUnit - TimeUnit for maxIdle
      Returns:
      true if the value was replaced
    • replaceWithVersionAsync

      public final CompletableFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version)
      Specified by:
      replaceWithVersionAsync in interface RemoteCache<K,V>
      See Also:
    • replaceWithVersionAsync

      public final CompletableFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, int lifespanSeconds)
      Specified by:
      replaceWithVersionAsync in interface RemoteCache<K,V>
      See Also:
    • replaceWithVersionAsync

      public final CompletableFuture<Boolean> replaceWithVersionAsync(K key, V newValue, long version, int lifespanSeconds, int maxIdleSeconds)
      Specified by:
      replaceWithVersionAsync in interface RemoteCache<K,V>
      See Also:
    • remove

      public final V remove(Object key)
      Description copied from interface: RemoteCache
      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).

      The returned value is only sent back if Flag.FORCE_RETURN_VALUE is enabled.

      Specified by:
      remove in interface BasicCache<K,V>
      Specified by:
      remove in interface Map<K,V>
      Specified by:
      remove in interface RemoteCache<K,V>
    • removeAsync

      public abstract 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
    • remove

      public final boolean remove(Object key, Object value)
      Description copied from interface: RemoteCache

      This method requires 2 round trips to the server. The first to retrieve the value and version and a second to remove the key with the version if the value matches. If possible user should use RemoteCache.getWithMetadata(Object) and RemoteCache.removeWithVersion(Object, long).

      Specified by:
      remove in interface ConcurrentMap<K,V>
      Specified by:
      remove in interface Map<K,V>
      Specified by:
      remove in interface RemoteCache<K,V>
    • removeAsync

      public abstract 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
    • removeWithVersion

      public final boolean removeWithVersion(K key, long version)
      Description copied from interface: RemoteCache
      Removes the given entry only if its version matches the supplied version. A typical use case looks like this:
       VersionedEntry ve = remoteCache.getVersioned(key);
       //some processing
       remoteCache.removeWithVersion(key, ve.getVersion();
       
      Lat call (removeWithVersion) will make sure that the entry will only be removed if it hasn't been changed in between.
      Specified by:
      removeWithVersion in interface RemoteCache<K,V>
      Returns:
      true if the entry has been removed
      See Also:
    • removeWithVersionAsync

      public abstract CompletableFuture<Boolean> removeWithVersionAsync(K key, long version)
      Specified by:
      removeWithVersionAsync in interface RemoteCache<K,V>
      See Also:
    • merge

      public final V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
      Specified by:
      merge in interface ConcurrentMap<K,V>
      Specified by:
      merge in interface Map<K,V>
    • merge

      public final 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 final 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
    • mergeAsync

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

      public final 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 abstract 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>
    • clear

      public final void clear()
      Specified by:
      clear in interface Map<K,V>
    • compute

      public final V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
      Specified by:
      compute in interface ConcurrentMap<K,V>
      Specified by:
      compute in interface Map<K,V>
    • compute

      public final 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 final 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
    • computeAsync

      public final 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 final 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 abstract 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>
    • computeIfAbsent

      public final V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
      Specified by:
      computeIfAbsent in interface ConcurrentMap<K,V>
      Specified by:
      computeIfAbsent in interface Map<K,V>
    • computeIfAbsent

      public final 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 final 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
    • computeIfAbsentAsync

      public final 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 final 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 abstract 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>
    • computeIfPresent

      public final V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
      Specified by:
      computeIfPresent in interface ConcurrentMap<K,V>
      Specified by:
      computeIfPresent in interface Map<K,V>
    • computeIfPresent

      public final 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 final 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
    • computeIfPresentAsync

      public final 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 final 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 abstract 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>
    • replaceAll

      public abstract 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>
    • size

      public final int size()
      Specified by:
      size in interface Map<K,V>
    • sizeAsync

      public abstract 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