javax.cache
Interface Cache.EntryProcessor<K,V,T>
- Type Parameters:
K
- the type of keys maintained by this cacheV
- the type of cached values
- Enclosing interface:
- Cache<K,V>
public static interface Cache.EntryProcessor<K,V,T>
Allows execution of code which may mutate a cache entry with exclusive
access (including reads) to that entry.
Any mutations will not take effect till after the processor has completed; if an exception
thrown inside the processor, the exception will be returned wrapped in an
ExecutionException. No changes will be made to the cache.
This enables a way to perform compound operations without transactions
involving a cache entry atomically. Such operations may include mutations.
The mutations can be potentially done in place avoiding expensive network transfers.
An example is a value which is a list and you simply want to append a new element to it.
An entry processor cannot invoke any cache operations, including processor operations.
If executed in a JVM remote from the one invoke was called in, an EntryProcessor equal
to the local one will execute the invocation. For remote to execution to succeed, the
EntryProcessor implementation class must be in the executing class loader as must K and
V if Cache.Entry.getKey()
or Cache.Entry.getValue()
is invoked.
- Author:
- Greg Luck, Yannis Cosmadopoulos
process
T process(Cache.MutableEntry<K,V> entry)
- Process an entry. Exclusive read and write access to the entry is obtained to
the entry.
- Parameters:
entry
- the entry
- Returns:
- the result
Copyright © 2013. All Rights Reserved.