Interface Listeners.ReadWriteListeners<K,​V>

  • All Superinterfaces:
    Listeners.WriteListeners<K,​V>
    Enclosing class:
    Listeners

    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
    • Method Detail

      • onCreate

        java.lang.AutoCloseable onCreate​(java.util.function.Consumer<EntryView.ReadEntryView<K,​V>> f)
        Add a create event specific listener by passing in a Consumer to be called back each time a new cache entry is created, passing in a EntryView.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

        java.lang.AutoCloseable onModify​(java.util.function.BiConsumer<EntryView.ReadEntryView<K,​V>,​EntryView.ReadEntryView<K,​V>> f)
        Add a modify/update event specific listener by passing in a BiConsumer to be called back each time an entry is modified or updated, passing in a EntryView.ReadEntryView of the previous entry as first parameter, and a EntryView.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 the EntryView.ReadEntryView of the previous entry value, and the second parameter the new EntryView.ReadEntryView
        Returns:
        an AutoCloseable instance that can be used to unregister the listener
      • onRemove

        java.lang.AutoCloseable onRemove​(java.util.function.Consumer<EntryView.ReadEntryView<K,​V>> f)
        Add a remove event specific listener by passing in a Consumer to be called back each time an entry is removed, passing in the EntryView.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's EntryView.ReadEntryView as parameter.
        Returns:
        an AutoCloseable instance that can be used to unregister the listener
      • add

        java.lang.AutoCloseable add​(Listeners.ReadWriteListeners.ReadWriteListener<K,​V> l)
        Add a read-write listener, and return an AutoCloseable 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