Would like Caffeine instance builder to support an objectServedFromCacheListener #555
Replies: 1 comment
-
The primary use-case for this is for statistics, which you can enable on the builder. That can be given its own Otherwise you can manually intercept via a |
Beta Was this translation helpful? Give feedback.
-
When creating a Caffeine bean the builder is used as in the following example:
@bean
public Caffeine caffeineConfig() {
return Caffeine.newBuilder().maximumSize(1000).expireAfterWrite(4, TimeUnit.HOURS);
}
The builder has a removalListener() to attach a listener for removal events. I wish there was such an easy way to attach a listener for other events such as cache hits and misses. My particular use case needed a objectServedFromCacheListener, but I can see this request easily extended to support objectNotInCacheListener and objectSavedInCacheListener.
Beta Was this translation helpful? Give feedback.
All reactions