/** * - Sends eviction event. - Invalidates near cache. * * @param key the key to be processed. * @param value the value to be processed. */ @Override public void doPostEvictionOperations(Data key, Object value, boolean isExpired) { MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher(); NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); EventService eventService = nodeEngine.getEventService(); if (!eventService.hasEventRegistration(SERVICE_NAME, name)) { return; } Address thisAddress = nodeEngine.getThisAddress(); // Fire EVICTED event also in case of expiration because historically eviction-listener // listens all kind of eviction and expiration events and by firing EVICTED event we are // preserving // this behavior. mapEventPublisher.publishEvent(thisAddress, name, EVICTED, key, value, null); if (isExpired) { // We will be in this if in two cases: // 1. In case of TTL or max-idle-seconds expiration. // 2. When evicting due to the size-based eviction, we are also firing an EXPIRED event // because there is a possibility that evicted entry may be also an expired one. Trying to // catch // as much as possible expired entries. mapEventPublisher.publishEvent(thisAddress, name, EXPIRED, key, value, null); } }
protected boolean hasRegisteredListenerForThisMap() { final EventService eventService = getNodeEngine().getEventService(); return eventService.hasEventRegistration(SERVICE_NAME, name); }