|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
K
- the type of the keys used to access data within the cacheV
- the type of the values held within the cachepublic interface CacheLoaderWriter<K,V>
A CacheLoaderWriter is associated with a given Cache
instance and will be used to keep it
in sync with another system.
Instances of this class have to be thread safe.
Any Exception
thrown by the loading methods of this interface will be wrapped into a
CacheLoadingException
by the Cache
and will need to be handled by
the user. Any java.lang.Exception
thrown by the writing methods will
be wrapped into a CacheWritingException
.
CacheLoadingException
,
CacheWritingException
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. |
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. |
Method Detail |
---|
V load(K key) throws java.lang.Exception
Cache
using this
CacheLoaderWriter
instance.
key
- the key that will map to the value
returned
java.lang.Exception
- if the value cannot be loadedjava.util.Map<K,V> loadAll(java.lang.Iterable<? extends K> keys) throws java.lang.Exception
Cache
using this
CacheLoaderWriter
instance. The returned Map
should contain
null
mapped keys for values that couldn't be found.
key
as found in the input parameter keys
mapped to the result of loadAllResult.get(key)
. Any other mapping will be ignored.
keys
- the keys that will be mapped to the values returned in the map
Map
of values for each key passed in, where no mapping means no value to map.
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 casevoid write(K key, V value) throws java.lang.Exception
key
- the key of the mapping being installed or updatedvalue
- the actual value being updated
java.lang.Exception
- if the write operation failedCache.put(Object, Object)
void writeAll(java.lang.Iterable<? extends java.util.Map.Entry<? extends K,? extends V>> entries) throws BulkCacheWritingException, java.lang.Exception
BulkCacheWritingException
must be thrown (see below)
entries
- the key to value mappings
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 caseCache.putAll(java.util.Map)
void delete(K key) throws java.lang.Exception
key
- the key to delete
java.lang.Exception
- if the write operation failedCache.remove(Object)
void deleteAll(java.lang.Iterable<? extends K> keys) throws BulkCacheWritingException, java.lang.Exception
BulkCacheWritingException
must be thrown (see below)
keys
- the keys to delete
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 caseCache.removeAll(java.util.Set)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |