Class LazyBasicCache<K,​V,​C extends org.infinispan.commons.api.BasicCache<K,​V>>

  • All Implemented Interfaces:
    PrivilegedAction<C>, ConcurrentMap<K,​V>, Supplier<C>, Map<K,​V>, org.infinispan.commons.api.AsyncCache<K,​V>, org.infinispan.commons.api.BasicCache<K,​V>, org.infinispan.commons.api.Lifecycle
    Direct Known Subclasses:
    LazyCache

    public abstract class LazyBasicCache<K,​V,​C extends org.infinispan.commons.api.BasicCache<K,​V>>
    extends Object
    implements org.infinispan.commons.api.BasicCache<K,​V>, Supplier<C>, PrivilegedAction<C>
    A cache that resolves itself from its cache container lazily.
    Author:
    Paul Ferraro
    • Constructor Detail

      • LazyBasicCache

        protected LazyBasicCache​(String name)
    • Method Detail

      • get

        public C get()
        Specified by:
        get in interface Supplier<K>
      • getName

        public String getName()
        Specified by:
        getName in interface org.infinispan.commons.api.BasicCache<K,​V>
      • start

        public void start()
        Specified by:
        start in interface org.infinispan.commons.api.Lifecycle
      • stop

        public void stop()
        Specified by:
        stop in interface org.infinispan.commons.api.Lifecycle
      • getVersion

        public String getVersion()
        Specified by:
        getVersion in interface org.infinispan.commons.api.BasicCache<K,​V>
      • containsKey

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

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

        public Set<K> keySet()
        Specified by:
        keySet in interface Map<K,​V>
      • clear

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

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

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

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

        public V get​(Object key)
        Specified by:
        get 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)
        Specified by:
        merge in interface org.infinispan.commons.api.BasicCache<K,​V>
      • merge

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

        public 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 V put​(K key,
                     V value,
                     long lifespan,
                     TimeUnit lifespanUnit)
        Specified by:
        put in interface org.infinispan.commons.api.BasicCache<K,​V>
      • put

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

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

        public void putAll​(Map<? extends K,​? extends V> map,
                           long lifespan,
                           TimeUnit lifespanUnit)
        Specified by:
        putAll in interface org.infinispan.commons.api.BasicCache<K,​V>
      • putAll

        public void putAll​(Map<? extends K,​? extends V> map,
                           long lifespan,
                           TimeUnit lifespanUnit,
                           long maxIdle,
                           TimeUnit maxIdleUnit)
        Specified by:
        putAll in interface org.infinispan.commons.api.BasicCache<K,​V>
      • putIfAbsent

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

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

        public V remove​(Object key)
        Specified by:
        remove in interface org.infinispan.commons.api.BasicCache<K,​V>
        Specified by:
        remove in interface Map<K,​V>
      • replace

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

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

        public boolean replace​(K key,
                               V oldValue,
                               V newValue,
                               long lifespan,
                               TimeUnit lifespanUnit)
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
      • replace

        public boolean replace​(K key,
                               V oldValue,
                               V newValue,
                               long lifespan,
                               TimeUnit lifespanUnit,
                               long maxIdle,
                               TimeUnit maxIdleUnit)
        Specified by:
        replace in interface org.infinispan.commons.api.BasicCache<K,​V>
      • size

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

        public CompletableFuture<Void> clearAsync()
        Specified by:
        clearAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • computeAsync

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

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

        public 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 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 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>
      • getAsync

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

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

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

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

        public 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>
      • putAllAsync

        public CompletableFuture<Void> putAllAsync​(Map<? extends K,​? extends V> entries)
        Specified by:
        putAllAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • putAllAsync

        public CompletableFuture<Void> putAllAsync​(Map<? extends K,​? extends V> entries,
                                                   long lifespan,
                                                   TimeUnit lifespanUnit)
        Specified by:
        putAllAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • putAllAsync

        public CompletableFuture<Void> putAllAsync​(Map<? extends K,​? extends V> entries,
                                                   long lifespan,
                                                   TimeUnit lifespanUnit,
                                                   long maxIdle,
                                                   TimeUnit maxIdleUnit)
        Specified by:
        putAllAsync in interface org.infinispan.commons.api.AsyncCache<K,​V>
      • putIfAbsentAsync

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

        public 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 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>
      • removeAsync

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

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

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

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

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

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

        public 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>
      • sizeAsync

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