Interface Listeners.WriteListeners<K,V>
- All Known Subinterfaces:
FunctionalNotifier<K,,V> Listeners.ReadWriteListeners<K,V>
- All Known Implementing Classes:
FunctionalNotifierImpl
- Enclosing class:
- Listeners
Listeners for write events cannot distinguish between cache entry created and cache entry modify/update events because they don't have access to the previous value. All they know is that a new non-null entry has been written.
However, write event listeners can distinguish between entry removals
and cache entry create/modify-update events because they can query
what the new entry's value via EntryView.ReadEntryView.find().
- Since:
- 8.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceWrite-only listener. -
Method Summary
Modifier and TypeMethodDescriptionAdd a write-only listener, and return anAutoCloseableinstance that can be used to remove the listener registration.Add a write event listener by passing in aConsumerto be called each time a cache entry is created, modified/updated or removed.
-
Method Details
-
onWrite
Add a write event listener by passing in aConsumerto be called each time a cache entry is created, modified/updated or removed.For created or modified/updated events, the
EntryView.ReadEntryViewpassed in will represent the newly stored entry, hence implementations will not be available to differentiate between created events vs modified/updated events.For removed events,
EntryView.ReadEntryViewpassed in will represent an empty entry view, henceEntryView.ReadEntryView.find()will return an emptyOptionalinstance, andEntryView.ReadEntryView.get()will throwNoSuchElementException.- Parameters:
f- operation to be called each time a cache entry is written- Returns:
- an
AutoCloseableinstance that can be used to unregister the listener
-
add
Add a write-only listener, and return anAutoCloseableinstance that can be used to remove the listener registration.- Parameters:
l- the write-only functional map event listener- Returns:
- an
AutoCloseableinstance that can be used to unregister the listener
-