I am using caffeine in the following configuration:
Cache<String, String> cache = Caffeine.newBuilder()
.executor(newWorkStealingPool(15))
.scheduler(createScheduler())
.expireAfterWrite(10, TimeUnit.SECONDS)
.maximumSize(MAXIMUM_CACHE_SIZE)
.removalListener(this::onRemoval)
.build();
private Scheduler createScheduler() {
return forScheduledExecutorService(newSingleThreadScheduledExecutor());
}
will I be correct to assume that onRemoval
method will be executed on the newWorkStealingPool(15)
ForkJoinPool, and the scheduler will be invoked only to find the expired entries that needs to be evicted?
meaning it will go something like this:
- single thread scheduler is invoked (every ~ 1 second)
- find all the expired entries to be evicted
- execute onRemoval for each of the evicted entries in the
newWorkStealingPool(15)
define in the cache builder?
I didn't found documentation that explains this behavior, so I am asking here
Tnx