RemovalListener Internal working for callback on expireAfterCreate #493
-
|
@ben-manes |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
It sounds like you want to use a scheduler to evict the entry when no other activity on the cache is occurring. Please see this wiki page for more details. LoadingCache<Key, Graph> graphs = Caffeine.newBuilder()
.scheduler(Scheduler.systemScheduler())
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(key -> createExpensiveGraph(key));The |
Beta Was this translation helpful? Give feedback.
It sounds like you want to use a scheduler to evict the entry when no other activity on the cache is occurring. Please see this wiki page for more details.
The
Scheduler.systemScheduler()is available in Java 9+ and uses a JVM provided thread, or else you can provide aScheduledExecutorService. The cache will peek at the next entry to expire and schedule acleanUp()call.