I'm using Guava cache as non-loading cache in my project and set the max size and expire after write
CacheBuilder.newBuilder()
.expireAfterWrite(1h)
.maximumSize(5000)
.recordStats()
I used the cache in a multi-thread environment and i'm populating the cache using some custom load method, by which i'm doing something like:
lock(key)
1. Check if key is present in cache
2. if not, spin up an sync cache retrieval request(it's a future) and cache the request in an internal map(if there are following requests asking for same key, i will just return the cached retrieval request)
After deploying the application, i noticed some weird eviction behavior: The cache starts to evict at size around 1000 and at time around 20 minutes after the application has started.
Has anyone experienced this situation before?
Thanks!