com.atlassian.confluence.cache
Class DeferredOperationsCache<K,V>

java.lang.Object
  extended by com.atlassian.confluence.cache.CacheAdapter<K,V>
      extended by com.atlassian.confluence.cache.DeferredOperationsCache<K,V>
All Implemented Interfaces:
com.atlassian.cache.Cache<K,V>

public class DeferredOperationsCache<K,V>
extends CacheAdapter<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.


Constructor Summary
DeferredOperationsCache(com.atlassian.cache.Cache<K,V> delegate)
          Construct a deferred operations cache wrapper
 
Method Summary
 void clear()
          Clear the underlying object.
 boolean containsKey(K key)
           
static
<K,V> DeferredOperationsCache<K,V>
create(com.atlassian.cache.CacheFactory cacheFactory, java.lang.String cacheName, com.atlassian.cache.CacheLoader<K,V> loader, com.atlassian.cache.CacheSettings required)
           
 V get(K key)
           
 java.util.Collection<K> getKeys()
           
 java.lang.String getName()
          Return name of the deferred object
 java.lang.String getType()
          Return human readable type of the object
 boolean hasDeferredOperations()
          Return true if the deferred has operations requiring synchronisation.
 void put(K key, V value)
           
 void remove(K key)
           
 void removeAll()
           
 void sync()
          Perform synchronization.
 
Methods inherited from class com.atlassian.confluence.cache.CacheAdapter
getDelegate, getName, putIfAbsent, remove, replace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeferredOperationsCache

public DeferredOperationsCache(com.atlassian.cache.Cache<K,V> delegate)
Construct a deferred operations cache wrapper

Parameters:
delegate - Cache to wrap
Method Detail

create

public static <K,V> DeferredOperationsCache<K,V> create(com.atlassian.cache.CacheFactory cacheFactory,
                                                        java.lang.String cacheName,
                                                        com.atlassian.cache.CacheLoader<K,V> loader,
                                                        com.atlassian.cache.CacheSettings required)

get

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

containsKey

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

getKeys

public java.util.Collection<K> getKeys()
Specified by:
getKeys in interface com.atlassian.cache.Cache<K,V>
Overrides:
getKeys in class CacheAdapter<K,V>

put

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

remove

public void remove(K key)
Specified by:
remove in interface com.atlassian.cache.Cache<K,V>
Overrides:
remove in class CacheAdapter<K,V>

removeAll

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

hasDeferredOperations

public boolean hasDeferredOperations()
Return true if the deferred has operations requiring synchronisation.

Returns:
true if the deferred has operations

getType

public java.lang.String getType()
Return human readable type of the object

Returns:
human readable type of the object

clear

public void clear()
Clear the underlying object.


sync

public void sync()
Perform synchronization.


getName

public java.lang.String getName()
Return name of the deferred object

Returns:
name of the deferred object


Copyright © 2003-2014 Atlassian. All Rights Reserved.