Interface Listeners.ReadWriteListeners<K,V>
-
- All Superinterfaces:
Listeners.WriteListeners<K,V>
- Enclosing class:
- Listeners
@Experimental public static interface Listeners.ReadWriteListeners<K,V> extends Listeners.WriteListeners<K,V>
Read-write listeners enable users to register listeners for cache entry created, modified and removed events, and also register listeners for any cache entry write events.Entry created, modified and removed events can only be fired when these originate on a read-write functional map, since this is the only one that guarantees that the previous value has been read, and hence the differentiation between create, modified and removed can be fully guaranteed.
- Since:
- 8.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Listeners.ReadWriteListeners.ReadWriteListener<K,V>
Read-write listener-
Nested classes/interfaces inherited from interface org.infinispan.functional.Listeners.WriteListeners
Listeners.WriteListeners.WriteListener<K,V>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AutoCloseable
add(Listeners.ReadWriteListeners.ReadWriteListener<K,V> l)
Add a read-write listener, and return anAutoCloseable
instance that can be used to remove the listener registration.AutoCloseable
onCreate(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a create event specific listener by passing in aConsumer
to be called back each time a new cache entry is created, passing in aEntryView.ReadEntryView
of that new entry.AutoCloseable
onModify(BiConsumer<EntryView.ReadEntryView<K,V>,EntryView.ReadEntryView<K,V>> f)
Add a modify/update event specific listener by passing in aBiConsumer
to be called back each time an entry is modified or updated, passing in aEntryView.ReadEntryView
of the previous entry as first parameter, and aEntryView.ReadEntryView
of the new value as second parameter.AutoCloseable
onRemove(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a remove event specific listener by passing in aConsumer
to be called back each time an entry is removed, passing in theEntryView.ReadEntryView
of the removed entry.-
Methods inherited from interface org.infinispan.functional.Listeners.WriteListeners
add, onWrite
-
-
-
-
Method Detail
-
onCreate
AutoCloseable onCreate(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a create event specific listener by passing in aConsumer
to be called back each time a new cache entry is created, passing in aEntryView.ReadEntryView
of that new entry.This method is shortcut for users who are only interested in create events. If interested in multiple event types, calling
add(ReadWriteListener)
is recommended instead.- Parameters:
f
- operation to be called each time a new cache entry is created- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
onModify
AutoCloseable onModify(BiConsumer<EntryView.ReadEntryView<K,V>,EntryView.ReadEntryView<K,V>> f)
Add a modify/update event specific listener by passing in aBiConsumer
to be called back each time an entry is modified or updated, passing in aEntryView.ReadEntryView
of the previous entry as first parameter, and aEntryView.ReadEntryView
of the new value as second parameter.This method is shortcut for users who are only interested in update events. If interested in multiple event types, calling
add(ReadWriteListener)
is recommended instead.- Parameters:
f
- operation to be called each time a new cache entry is modified or updated, with the first parameter theEntryView.ReadEntryView
of the previous entry value, and the second parameter the newEntryView.ReadEntryView
- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
onRemove
AutoCloseable onRemove(Consumer<EntryView.ReadEntryView<K,V>> f)
Add a remove event specific listener by passing in aConsumer
to be called back each time an entry is removed, passing in theEntryView.ReadEntryView
of the removed entry.This method is shortcut for users who are only interested in remove events. If interested in multiple event types, calling
add(ReadWriteListener)
is recommended instead.- Parameters:
f
- operation to be called each time a new cache entry is removed, with the old cached entry'sEntryView.ReadEntryView
as parameter.- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
add
AutoCloseable add(Listeners.ReadWriteListeners.ReadWriteListener<K,V> l)
Add a read-write listener, and return anAutoCloseable
instance that can be used to remove the listener registration.- Parameters:
l
- the read-write functional map event listener- Returns:
- an
AutoCloseable
instance that can be used to unregister the listener
-
-