I want to be notified when a whole cache region is cleared.
How can I register a listener for this type of event?
Cache event listeners are used only for entry scope operation, but I want to listen for whole cache clear event.
I want to be notified when a whole cache region is cleared.
How can I register a listener for this type of event?
Cache event listeners are used only for entry scope operation, but I want to listen for whole cache clear event.
in ehcache version 2.x, this was done elementarily through a listener;
cache.getCacheEventNotificationService().registerListener(new CacheEventListener() {
@Override
public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException {
}
@Override
public void notifyElementPut(Ehcache cache, Element element) throws CacheException {
}
@Override
public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException {
}
@Override
public void notifyElementExpired(Ehcache cache, Element element) {
}
@Override
public void notifyElementEvicted(Ehcache cache, Element element) {
}
@Override
public void notifyRemoveAll(Ehcache cache) {
}
@Override
public void dispose() {
}
@Override
public Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
});
it turns out in the 3.h version, there are no more such events and have to fiddle with aspects and other redundant code?
Workaround using aspectj:
Usage: