Class DeferredOperationsCache<K,V>

java.lang.Object
com.atlassian.confluence.cache.DefaultConfluenceCache<K,V>
com.atlassian.confluence.cache.DeferredOperationsCache<K,V>
All Implemented Interfaces:
com.atlassian.cache.Cache<K,V>, com.atlassian.cache.ManagedCache, ConfluenceCache<K,V>

public class DeferredOperationsCache<K,V> extends DefaultConfluenceCache<K,V>
An implementation of Cache that records changes to a delegate cache, only actually performing them when sync() is called. Deferred operations are still visible to the client, the actions are just not taken on the delegate cache.

For example, calling put(Object, Object) will not update the delegate cache, but the value will still be recorded for subsequent calls to get(Object) for the same key. Once sync() is called, the new value will be inserted in the delegate cache.

Objects of this class are NOT thread-safe. It is the client's responsibility to ensure serialized access to this object.

  • Method Details

    • create

      public static <K, V> DeferredOperationsCache<K,V> create(com.atlassian.cache.Cache<K,V> delegate, com.atlassian.cache.CacheLoader<K,V> loader)
    • get

      public V get(@NonNull K key)
      Specified by:
      get in interface com.atlassian.cache.Cache<K,V>
      Overrides:
      get in class DefaultConfluenceCache<K,V>
    • get

      public @NonNull V get(@NonNull K key, @NonNull com.atlassian.cache.Supplier<? extends V> supplier)
      Specified by:
      get in interface com.atlassian.cache.Cache<K,V>
      Overrides:
      get in class DefaultConfluenceCache<K,V>
    • containsKey

      public boolean containsKey(@NonNull K key)
      Specified by:
      containsKey in interface com.atlassian.cache.Cache<K,V>
      Overrides:
      containsKey in class DefaultConfluenceCache<K,V>
    • getKeys

      public @NonNull Collection<K> getKeys()
      Specified by:
      getKeys in interface com.atlassian.cache.Cache<K,V>
      Overrides:
      getKeys in class DefaultConfluenceCache<K,V>
    • put

      public void put(@NonNull K key, @NonNull V value)
      Specified by:
      put in interface com.atlassian.cache.Cache<K,V>
      Overrides:
      put in class DefaultConfluenceCache<K,V>
    • remove

      public void remove(@NonNull K key)
      Specified by:
      remove in interface com.atlassian.cache.Cache<K,V>
      Overrides:
      remove in class DefaultConfluenceCache<K,V>
    • removeAll

      public void removeAll()
      Specified by:
      removeAll in interface com.atlassian.cache.Cache<K,V>
      Overrides:
      removeAll in class DefaultConfluenceCache<K,V>
    • hasDeferredOperations

      public boolean hasDeferredOperations()
    • getType

      public String getType()
    • clear

      public void clear()
      Specified by:
      clear in interface com.atlassian.cache.ManagedCache
      Overrides:
      clear in class DefaultConfluenceCache<K,V>
    • sync

      public void sync()
    • getName

      String getName()
      Return name of the deferred object
      Returns:
      name of the deferred object