Interface CacheEntryProcessor<K,V,R>
- Type Parameters:
K- the type of the keyV- the type of the valueR- the type of the result returned by the processor
- All Known Subinterfaces:
ReadOnlyCacheEntryProcessor<K,V, R>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Processes map entries in-place with strong atomicity guarantees.
Each processor execution is atomic with respect to the target entry: the full read-process-write sequence is serialized with concurrent mutations on that key while the processor is executing.
Usage:
CacheEntryProcessorinvalid input: '<'String, Integer, Integer> incrementer = entry -> {
int value = entry.value() != null ? entry.value() : 0;
entry.setValue(value + 1);
return value + 1;
};
Integer result = map.processEntry("counter", incrementer);
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents a mutable entry in the map during processing. -
Method Summary
Modifier and TypeMethodDescription@Nullable Rprocess(CacheEntryProcessor.Entry<K, V> entry) Process the given entry atomically.
-
Method Details
-
process
Process the given entry atomically.- Parameters:
entry- the entry to process (mutable view into the map, must not be null)- Returns:
- the result of processing
-