public static interface Listeners.WriteListeners<K,V>
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()
.
Modifier and Type | Interface and Description |
---|---|
static interface |
Listeners.WriteListeners.WriteListener<K,V>
Write-only listener.
|
Modifier and Type | Method and Description |
---|---|
AutoCloseable |
add(Listeners.WriteListeners.WriteListener<K,V> l)
Add a write-only listener, and return an
AutoCloseable
instance that can be used to remove the listener registration. |
AutoCloseable |
onWrite(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a write event listener by passing in a
Consumer to be
called each time a cache entry is created, modified/updated or
removed. |
AutoCloseable onWrite(Consumer<EntryView.ReadEntryView<K,V>> f)
Consumer
to be
called each time a cache entry is created, modified/updated or
removed.
For created or modified/updated events, the
EntryView.ReadEntryView
passed 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.ReadEntryView
passed in will represent
an empty entry view, hence EntryView.ReadEntryView.find()
will return
an empty Optional
instance, and
EntryView.ReadEntryView.get()
will throw
NoSuchElementException
.
f
- operation to be called each time a cache entry is writtenAutoCloseable
instance that can be used to
unregister the listenerAutoCloseable add(Listeners.WriteListeners.WriteListener<K,V> l)
AutoCloseable
instance that can be used to remove the listener registration.l
- the write-only functional map event listenerAutoCloseable
instance that can be used to
unregister the listenerCopyright © 2015 JBoss, a division of Red Hat. All rights reserved.