CacheEventListenerConfigurationBuilder cacheEventListenerConfiguration = CacheEventListenerConfigurationBuilder
.newEventListenerConfiguration(new MyListener(), EventType.EXPIRED)
.unordered().asynchronous();
CacheManagerBuilder.newCacheManagerBuilder()
.with(CacheManagerBuilder.
persistence(System.getProperty("java.io.tmpdir") + File.separator + "myCache"))
.withCache("myCache", CacheConfigurationBuilder
.newCacheConfigurationBuilder(Tuple3.class, Integer.class,
ResourcePoolsBuilder.heap(500)
.disk(200, MemoryUnit.MB)
)
.add(cacheEventListenerConfiguration)
.withExpiry(Expirations.timeToIdleExpiration(Duration.of(30, TimeUnit.SECONDS)))
.build()
)
private class MyListener implements CacheEventListener<Tuple3<String, String, String>, Integer> {
@Override
public void onEvent(CacheEvent<Tuple3<String, String, String>, Integer> event) {
}
}
I imagined there is a background thread that is notifying for expired items in the cache. However the listener seems to trigger only in case I issue a get for the expired element.
Is there a way to make the notification trigger even without getting the element?