org.ehcache.loaderwriter.writebehind
Class WriteBehindDecoratorLoaderWriter<K,V>

java.lang.Object
  extended by org.ehcache.loaderwriter.writebehind.WriteBehindDecoratorLoaderWriter<K,V>
All Implemented Interfaces:
CacheLoaderWriter<K,V>

public class WriteBehindDecoratorLoaderWriter<K,V>
extends java.lang.Object
implements CacheLoaderWriter<K,V>


Constructor Summary
WriteBehindDecoratorLoaderWriter(CacheLoaderWriter<K,V> loaderWriter, WriteBehindConfiguration config)
           
 
Method Summary
 void delete(K key)
          Deletes a single entry from the underlying system of record.
 void deleteAll(java.lang.Iterable<? extends K> keys)
          Deletes a set of entry from the underlying system of record.
 AggregateWriteBehindQueue<K,V> getWriteBehindQueue()
           
 V load(K key)
          Loads the value to be associated with the given key in the Cache using this CacheLoaderWriter instance.
 java.util.Map<K,V> loadAll(java.lang.Iterable<? extends K> keys)
          Loads the values to be associated with the keys in the Cache using this CacheLoaderWriter instance.
 void write(K key, V value)
          Writes a single entry to the underlying system of record, maybe a brand new value or an update to an existing value
 void writeAll(java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>> entries)
          Writes multiple entries to the underlying system of record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteBehindDecoratorLoaderWriter

public WriteBehindDecoratorLoaderWriter(CacheLoaderWriter<K,V> loaderWriter,
                                        WriteBehindConfiguration config)
Method Detail

getWriteBehindQueue

public AggregateWriteBehindQueue<K,V> getWriteBehindQueue()

load

public V load(K key)
       throws java.lang.Exception
Description copied from interface: CacheLoaderWriter
Loads the value to be associated with the given key in the Cache using this CacheLoaderWriter instance.

Specified by:
load in interface CacheLoaderWriter<K,V>
Parameters:
key - the key that will map to the value returned
Returns:
the value to be mapped
Throws:
java.lang.Exception - if the value cannot be loaded

loadAll

public java.util.Map<K,V> loadAll(java.lang.Iterable<? extends K> keys)
                           throws java.lang.Exception
Description copied from interface: CacheLoaderWriter
Loads the values to be associated with the keys in the Cache using this CacheLoaderWriter instance. The returned Map should contain null mapped keys for values that couldn't be found.
The mapping that will be installed in the cache is the key as found in the input parameter keys mapped to the result of loadAllResult.get(key). Any other mapping will be ignored.

Specified by:
loadAll in interface CacheLoaderWriter<K,V>
Parameters:
keys - the keys that will be mapped to the values returned in the map
Returns:
the Map of values for each key passed in, where no mapping means no value to map.
Throws:
BulkCacheLoadingException - This writer must throw this exception to indicate partial success. The exception declares which keys were actually loaded (if any)
java.lang.Exception - a generic failure. All values will be considered not loaded in this case

write

public void write(K key,
                  V value)
           throws java.lang.Exception
Description copied from interface: CacheLoaderWriter
Writes a single entry to the underlying system of record, maybe a brand new value or an update to an existing value

Specified by:
write in interface CacheLoaderWriter<K,V>
Parameters:
key - the key of the mapping being installed or updated
value - the actual value being updated
Throws:
java.lang.Exception - if the write operation failed
See Also:
Cache.put(Object, Object)

writeAll

public void writeAll(java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>> entries)
              throws BulkCacheWritingException,
                     java.lang.Exception
Description copied from interface: CacheLoaderWriter
Writes multiple entries to the underlying system of record. These can either be new entries or updates to existing ones. It is legal for this method to result in "partial success" where some subset of the entries are written. In this case a BulkCacheWritingException must be thrown (see below)

Specified by:
writeAll in interface CacheLoaderWriter<K,V>
Parameters:
entries - the key to value mappings
Throws:
BulkCacheWritingException - This writer must throw this exception to indicate partial success. The exception declares which keys were actually written (if any)
java.lang.Exception - a generic failure. All entries will be considered not written in this case
See Also:
Cache.putAll(java.util.Map)

delete

public void delete(K key)
            throws java.lang.Exception
Description copied from interface: CacheLoaderWriter
Deletes a single entry from the underlying system of record.

Specified by:
delete in interface CacheLoaderWriter<K,V>
Parameters:
key - the key to delete
Throws:
java.lang.Exception - if the write operation failed
See Also:
Cache.remove(Object)

deleteAll

public void deleteAll(java.lang.Iterable<? extends K> keys)
               throws BulkCacheWritingException,
                      java.lang.Exception
Description copied from interface: CacheLoaderWriter
Deletes a set of entry from the underlying system of record. It is legal for this method to result in "partial success" where some subset of the keys are deleted. In this case a BulkCacheWritingException must be thrown (see below)

Specified by:
deleteAll in interface CacheLoaderWriter<K,V>
Parameters:
keys - the keys to delete
Throws:
BulkCacheWritingException - This writer must throw this exception to indicate partial success. The exception declares which keys were actually deleted (if any)
java.lang.Exception - a generic failure. All entries will be considered not deleted in this case
See Also:
Cache.removeAll(java.util.Set)