Class CacheSupport<K,​V>

  • All Implemented Interfaces:
    ConcurrentMap<K,​V>, Map<K,​V>, org.infinispan.commons.api.AsyncCache<K,​V>, org.infinispan.commons.api.BasicCache<K,​V>, org.infinispan.commons.api.Lifecycle

    public abstract class CacheSupport<K,​V>
    extends Object
    implements org.infinispan.commons.api.BasicCache<K,​V>
    Since:
    4.1
    Author:
    Mircea.Markus@jboss.com
    • Field Detail

      • defaultLifespan

        protected long defaultLifespan
      • defaultMaxIdleTime

        protected long defaultMaxIdleTime
    • Constructor Detail

      • CacheSupport

        protected CacheSupport()
      • CacheSupport

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

      • put

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

        protected abstract void set​(K key,
                                    V value)
        This is intentionally a non-public method meant as an integration point for bytecode manipulation. Don't remove or alter the signature even if it might look like unreachable code. Implementors should perform a put operation but optimizing it as return values are not required.
        Since:
        5.0
      • putAll

        public final void putAll​(Map<? extends K,​? extends V> map)
        Specified by:
        putAll in interface Map<K,​V>
      • putAsync

        public final CompletableFuture<V> putAsync​(K key,
                                                   V value)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.put(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        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: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.put(Object, Object, long, TimeUnit) . This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        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
      • putAllAsync

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

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

        public final CompletableFuture<V> putIfAbsentAsync​(K key,
                                                           V value)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of ConcurrentMap.putIfAbsent(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        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 unit)
        Description copied from interface: org.infinispan.commons.api.AsyncCache
        Asynchronous version of BasicCache.putIfAbsent(Object, Object, long, TimeUnit) . This method does not block on remote calls, even if your cache mode is synchronous.
        Specified by:
        putIfAbsentAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
        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
      • replaceAsync

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

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

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

        public final void putAll​(Map<? extends K,​? extends V> map,
                                 long lifespan,
                                 TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of Map.putAll(Map), which takes in lifespan parameters. Note that the lifespan is applied to all mappings in the map passed in.
        Specified by:
        putAll in interface org.infinispan.commons.api.BasicCache<K,​V>
        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 final V replace​(K key,
                               V value,
                               long lifespan,
                               TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.replace(Object, Object), which takes in lifespan parameters.
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
        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 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 final boolean replace​(K key,
                                     V oldValue,
                                     V value,
                                     long lifespan,
                                     TimeUnit unit)
        Description copied from interface: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
        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
      • 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: org.infinispan.commons.api.BasicCache
        An overloaded form of ConcurrentMap.merge(Object, Object, BiFunction) which takes in lifespan parameters.
        Specified by:
        merge in interface org.infinispan.commons.api.BasicCache<K,​V>
        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