I am using LoadingCache in CaffeineCache. I set refreshAfterWrite to 30 minute and checked the stats by Caffeine.stats(). I expected the loadSuccessCount value will be increased after 30 minutes but it's as same as before 30 minutes.
Below is code:
codeListCache = Caffeine.newBuilder()
.refreshAfterWrite(30, TimeUnit.MINUTES)
.recordStats()
.build(codeFilterNo -> loadCodeList(codeFilterNo));
codeListCache.getAll(codeFilterNoList);
Below is log which I was trying to check.
2020-04-13 00:13:42 [scheduling-1] INFO c.n.a.p.s.service.OlapTableService - CodeListCache Stats : CacheStats{hitCount=0, missCount=30, loadSuccessCount=30, loadFailureCount=0, totalLoadTime=2139529433, evictionCount=0, evictionWeight=0}
2020-04-13 01:08:42 [scheduling-1] INFO c.n.a.p.s.service.OlapTableService - CodeListCache Stats : CacheStats{hitCount=102, missCount=30, loadSuccessCount=30, loadFailureCount=0, totalLoadTime=2139529433, evictionCount=0, evictionWeight=0}
I can see the hitCount is growing but I'm not sure if the cache is reloaded successfully because the loadSuccessCount doesn't change.
I thought that refreshAfterWrite
will update the value per key 30 minutes after the last write and this would increase the 'loadSuccessCount'.
So my question is,
Can someone tell me if it is normal or a bug?
How can I check if the cache refresh work well?