Class RemoteCacheSupport<K,​V>

  • All Implemented Interfaces:
    ConcurrentMap<K,​V>, Map<K,​V>, RemoteCache<K,​V>, org.infinispan.commons.api.AsyncCache<K,​V>, org.infinispan.commons.api.BasicCache<K,​V>, org.infinispan.commons.api.Lifecycle, org.infinispan.commons.api.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 Detail

      • defaultLifespan

        protected long defaultLifespan
      • defaultMaxIdleTime

        protected long defaultMaxIdleTime
    • Constructor Detail

      • RemoteCacheSupport

        protected RemoteCacheSupport()
      • RemoteCacheSupport

        protected RemoteCacheSupport​(long defaultLifespan,
                                     long defaultMaxIdleTime)
    • Method Detail

      • 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 org.infinispan.commons.api.BasicCache<K,​V>
        Specified by:
        putAll in interface RemoteCache<K,​V>
      • putIfAbsent

        public final V putIfAbsent​(K key,
                                   V value,
                                   long lifespan,
                                   TimeUnit unit)
        Specified by:
        putIfAbsent in interface org.infinispan.commons.api.BasicCache<K,​V>
      • putIfAbsent

        public final V putIfAbsent​(K key,
                                   V value,
                                   long lifespan,
                                   TimeUnit lifespanUnit,
                                   long maxIdleTime,
                                   TimeUnit maxIdleTimeUnit)
        Specified by:
        putIfAbsent in interface org.infinispan.commons.api.BasicCache<K,​V>
      • putIfAbsentAsync

        public final CompletableFuture<V> putIfAbsentAsync​(K key,
                                                           V value)
        Specified by:
        putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • putIfAbsentAsync

        public final CompletableFuture<V> putIfAbsentAsync​(K key,
                                                           V value,
                                                           long lifespan,
                                                           TimeUnit lifespanUnit)
        Specified by:
        putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • putIfAbsentAsync

        public abstract CompletableFuture<V> putIfAbsentAsync​(K key,
                                                              V value,
                                                              long lifespan,
                                                              TimeUnit lifespanUnit,
                                                              long maxIdle,
                                                              TimeUnit maxIdleUnit)
        Specified by:
        putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • replaceAsync

        public final CompletableFuture<Boolean> replaceAsync​(K key,
                                                             V oldValue,
                                                             V newValue)
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • replaceAsync

        public final CompletableFuture<Boolean> replaceAsync​(K key,
                                                             V oldValue,
                                                             V newValue,
                                                             long lifespan,
                                                             TimeUnit unit)
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • replaceAsync

        public abstract CompletableFuture<Boolean> replaceAsync​(K key,
                                                                V oldValue,
                                                                V newValue,
                                                                long lifespan,
                                                                TimeUnit lifespanUnit,
                                                                long maxIdle,
                                                                TimeUnit maxIdleUnit)
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • replace

        public final V replace​(K key,
                               V value,
                               long lifespan,
                               TimeUnit unit)
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
      • replace

        public final V replace​(K key,
                               V value,
                               long lifespan,
                               TimeUnit lifespanUnit,
                               long maxIdleTime,
                               TimeUnit maxIdleTimeUnit)
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
      • replaceAsync

        public final CompletableFuture<V> replaceAsync​(K key,
                                                       V value)
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • replaceAsync

        public final CompletableFuture<V> replaceAsync​(K key,
                                                       V value,
                                                       long lifespan,
                                                       TimeUnit unit)
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • replaceAsync

        public abstract CompletableFuture<V> replaceAsync​(K key,
                                                          V value,
                                                          long lifespan,
                                                          TimeUnit lifespanUnit,
                                                          long maxIdle,
                                                          TimeUnit maxIdleUnit)
        Specified by:
        replaceAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • get

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

        public abstract CompletableFuture<V> getAsync​(K key)
        Specified by:
        getAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • 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)
        Specified by:
        getAllAsync in interface org.infinispan.commons.api.AsyncCache<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)
        Specified by:
        containsKeyAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • put

        public final V put​(K key,
                           V value)
        Specified by:
        put in interface org.infinispan.commons.api.BasicCache<K,​V>
        Specified by:
        put in interface Map<K,​V>
      • put

        public final V put​(K key,
                           V value,
                           long lifespan,
                           TimeUnit unit)
        Specified by:
        put in interface org.infinispan.commons.api.BasicCache<K,​V>
      • put

        public final V put​(K key,
                           V value,
                           long lifespan,
                           TimeUnit lifespanUnit,
                           long maxIdleTime,
                           TimeUnit maxIdleTimeUnit)
        Specified by:
        put in interface org.infinispan.commons.api.BasicCache<K,​V>
      • putAsync

        public final CompletableFuture<V> putAsync​(K key,
                                                   V value)
        Specified by:
        putAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • putAsync

        public final CompletableFuture<V> putAsync​(K key,
                                                   V value,
                                                   long lifespan,
                                                   TimeUnit unit)
        Specified by:
        putAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • putAsync

        public abstract CompletableFuture<V> putAsync​(K key,
                                                      V value,
                                                      long lifespan,
                                                      TimeUnit lifespanUnit,
                                                      long maxIdle,
                                                      TimeUnit maxIdleUnit)
        Specified by:
        putAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • 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
      • removeAsync

        public abstract CompletableFuture<V> removeAsync​(Object key)
        Specified by:
        removeAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • 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:
        VersionedValue, RemoteCache.getWithMetadata(Object)
      • merge

        public final V merge​(K key,
                             V value,
                             BiFunction<? super V,​? super V,​? extends V> remappingFunction,
                             long lifespan,
                             TimeUnit lifespanUnit)
        Specified by:
        merge in interface org.infinispan.commons.api.BasicCache<K,​V>
      • 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)
        Specified by:
        merge in interface org.infinispan.commons.api.BasicCache<K,​V>
      • mergeAsync

        public final CompletableFuture<V> mergeAsync​(K key,
                                                     V value,
                                                     BiFunction<? super V,​? super V,​? extends V> remappingFunction)
        Specified by:
        mergeAsync in interface org.infinispan.commons.api.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)
        Specified by:
        mergeAsync in interface org.infinispan.commons.api.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)
        Specified by:
        mergeAsync in interface org.infinispan.commons.api.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,
                               long lifespan,
                               TimeUnit lifespanUnit)
        Specified by:
        compute in interface org.infinispan.commons.api.BasicCache<K,​V>
      • compute

        public final V compute​(K key,
                               BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                               long lifespan,
                               TimeUnit lifespanUnit,
                               long maxIdleTime,
                               TimeUnit maxIdleTimeUnit)
        Specified by:
        compute in interface org.infinispan.commons.api.BasicCache<K,​V>
      • computeAsync

        public final CompletableFuture<V> computeAsync​(K key,
                                                       BiFunction<? super K,​? super V,​? extends V> remappingFunction)
        Specified by:
        computeAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • computeAsync

        public final CompletableFuture<V> computeAsync​(K key,
                                                       BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                                                       long lifespan,
                                                       TimeUnit lifespanUnit)
        Specified by:
        computeAsync in interface org.infinispan.commons.api.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)
        Specified by:
        computeAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • computeIfAbsent

        public final V computeIfAbsent​(K key,
                                       Function<? super K,​? extends V> mappingFunction,
                                       long lifespan,
                                       TimeUnit lifespanUnit)
        Specified by:
        computeIfAbsent in interface org.infinispan.commons.api.BasicCache<K,​V>
      • computeIfAbsent

        public final V computeIfAbsent​(K key,
                                       Function<? super K,​? extends V> mappingFunction,
                                       long lifespan,
                                       TimeUnit lifespanUnit,
                                       long maxIdleTime,
                                       TimeUnit maxIdleTimeUnit)
        Specified by:
        computeIfAbsent in interface org.infinispan.commons.api.BasicCache<K,​V>
      • computeIfAbsentAsync

        public final CompletableFuture<V> computeIfAbsentAsync​(K key,
                                                               Function<? super K,​? extends V> mappingFunction)
        Specified by:
        computeIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • computeIfAbsentAsync

        public final CompletableFuture<V> computeIfAbsentAsync​(K key,
                                                               Function<? super K,​? extends V> mappingFunction,
                                                               long lifespan,
                                                               TimeUnit lifespanUnit)
        Specified by:
        computeIfAbsentAsync in interface org.infinispan.commons.api.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)
        Specified by:
        computeIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • computeIfPresent

        public final V computeIfPresent​(K key,
                                        BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                                        long lifespan,
                                        TimeUnit lifespanUnit)
        Specified by:
        computeIfPresent in interface org.infinispan.commons.api.BasicCache<K,​V>
      • computeIfPresent

        public final V computeIfPresent​(K key,
                                        BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                                        long lifespan,
                                        TimeUnit lifespanUnit,
                                        long maxIdleTime,
                                        TimeUnit maxIdleTimeUnit)
        Specified by:
        computeIfPresent in interface org.infinispan.commons.api.BasicCache<K,​V>
      • computeIfPresentAsync

        public final CompletableFuture<V> computeIfPresentAsync​(K key,
                                                                BiFunction<? super K,​? super V,​? extends V> remappingFunction)
        Specified by:
        computeIfPresentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • computeIfPresentAsync

        public final CompletableFuture<V> computeIfPresentAsync​(K key,
                                                                BiFunction<? super K,​? super V,​? extends V> remappingFunction,
                                                                long lifespan,
                                                                TimeUnit lifespanUnit)
        Specified by:
        computeIfPresentAsync in interface org.infinispan.commons.api.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)
        Specified by:
        computeIfPresentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • size

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

        public abstract CompletableFuture<Long> sizeAsync()
        Specified by:
        sizeAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>