A tagging interface for cache entry listeners.
Sub-interfaces exist for the various cache events allowing a listener to be
created which implements only those listeners it is interested in.
Listeners should be implemented with care. In particular it is important to
consider their impact on performance and latency.
Listeners:
- are fired after the entry is mutated in the cache
- if synchronous are fired, for a given key, in the order in which events
occur
- block the calling thread until the listener returns,
where the listener was registered as synchronous
- which are asynchronous iterate through multiple events with an undefined
ordering, except that events on the same key are in the order in which the
events occur.
Listeners follow the observer pattern. An exception thrown by a
listener does not cause the cache operation to fail.
A listener which mutates a cache on the CacheManager may cause a deadlock.
Detection and response to deadlocks is implementation specific.
A listener on a transactional cache is executed orthogonally to the transaction.
If synchronous it is executed after the mutation and not after the transaction
commits, and if asynchronous the timing is undefined. A listener which throws
an exception will not affect the transaction. A transaction which is rolled back
will not unfire a listener.