K
- the type of keys maintained by this mapV
- the type of mapped valuespublic interface CacheWriter<K,V>
Cache
and is therefore not required to
be atomic in the writer. As individual writer operations can fail, cache
operations are not required to occur until after the writer batch method has
returned or, in the case of partial success, thrown an exception. In the case
of
partial success, the collection of entries must contain only those entries
which failed.
The semantics of Transactional Consistency are implementation specific.
The entry passed into write(Cache.Entry)
is independent
of the cache mapping for that key, meaning that if the value changes in the
cache or is removed it does not change the said entry.CacheLoader
Modifier and Type | Method and Description |
---|---|
void |
delete(Object key)
Delete the cache entry from the external resource.
|
void |
deleteAll(Collection<?> keys)
Remove data and keys from the external resource for the given collection of
keys, if present.
|
void |
write(Cache.Entry<? extends K,? extends V> entry)
Write the specified value under the specified key to the external resource.
|
void |
writeAll(Collection<Cache.Entry<? extends K,? extends V>> entries)
Write the specified entries to the external resource.
|
void write(Cache.Entry<? extends K,? extends V> entry) throws CacheWriterException
entry
- the entry to be writtenCacheWriterException
- if the write fails. If thrown the
cache mutation will not occur.void writeAll(Collection<Cache.Entry<? extends K,? extends V>> entries) throws CacheWriterException
Cache.putAll(java.util.Map)
also has undefined ordering.
If this operation fails (by throwing an exception) after a partial success,
the writer must remove any successfully written entries from the entries
collection so that the caching implementation knows what succeeded and can
mutate the cache.entries
- a mutable collection to write. Upon invocation, it contains
the entries to write for write-through. Upon return the
collection must only contain entries that were not
successfully written. (see partial success above)CacheWriterException
- if one or more of the writes fail. If
thrown cache mutations will occur for
entries which succeeded.void delete(Object key) throws CacheWriterException
key
- the key that is used for the delete operationCacheWriterException
- if delete fails. If thrown the cache delete will
not occur.void deleteAll(Collection<?> keys) throws CacheWriterException
Cache.removeAll(java.util.Set)
also has undefined ordering.
If this operation fails (by throwing an exception) after a partial success,
the writer must remove any successfully written entries from the entries
collection so that the caching implementation knows what succeeded and can
mutate the cache.
Expiry of a cache entry is not a delete hence will not cause this method to
be invoked.
This method is invoked even if no mapping for some or all of the keys exist.keys
- a mutable collection of keys for entries to delete. Upon
invocation, it contains the keys to delete for write-through.
Upon return the collection must only contain the keys that were
not successfully deleted. (see partial success above)CacheWriterException
- if one or more deletes fail. If thrown
cache deletes will occur for entries which
succeeded.Copyright © 2013. All Rights Reserved.