Class JCacheEvictionListener<K,V>
- java.lang.Object
-
- com.github.benmanes.caffeine.jcache.event.JCacheEvictionListener<K,V>
-
- All Implemented Interfaces:
RemovalListener<K,Expirable<V>>
public final class JCacheEvictionListener<K,V> extends java.lang.Object implements RemovalListener<K,Expirable<V>>
A listener that provides an adapter to publish events in the order of the actions being performed on a key.
-
-
Field Summary
Fields Modifier and Type Field Description private javax.cache.Cache<K,V>
cache
private EventDispatcher<K,V>
dispatcher
private JCacheStatisticsMXBean
statistics
-
Constructor Summary
Constructors Constructor Description JCacheEvictionListener(EventDispatcher<K,V> dispatcher, JCacheStatisticsMXBean statistics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onRemoval(K key, @Nullable Expirable<V> expirable, RemovalCause cause)
Notifies the listener that a removal occurred at some point in the past.void
setCache(javax.cache.Cache<K,V> cache)
Sets the cache instance that was created with this listener.
-
-
-
Field Detail
-
statistics
private final JCacheStatisticsMXBean statistics
-
dispatcher
private final EventDispatcher<K,V> dispatcher
-
-
Constructor Detail
-
JCacheEvictionListener
public JCacheEvictionListener(EventDispatcher<K,V> dispatcher, JCacheStatisticsMXBean statistics)
-
-
Method Detail
-
setCache
public void setCache(javax.cache.Cache<K,V> cache)
Sets the cache instance that was created with this listener.- Parameters:
cache
- the cache that uses this loader
-
onRemoval
public void onRemoval(K key, @Nullable Expirable<V> expirable, RemovalCause cause)
Description copied from interface:RemovalListener
Notifies the listener that a removal occurred at some point in the past.This does not always signify that the key is now absent from the cache, as it may have already been re-added.
- Specified by:
onRemoval
in interfaceRemovalListener<K,V>
- Parameters:
key
- the key represented by this entry, ornull
if collectedexpirable
- the value represented by this entry, ornull
if collectedcause
- the reason for which the entry was removed
-
-