I'm using Guava Cache to cache about 100K records in memory. I use cache.putAll(Map<K,V>) to pre-load the cache. After loading about 20K records, I see removal notifications with cause 'REPLACED'. Max size is 1GB and weigher returns 1 for all entries, expireAfterAccess is 24 hours. 1GB is enough for all records. How can I ensure that no entry is replaced before 24 hrs ?
MyCacheLoader cacheLoader = new MyCacheLoader();
CacheBuilder<Long, Map<String, List<String>>> cacheBuilder = CacheBuilder.newBuilder().
initialCapacity(1024 * 1024 * 1024).
//maximumSize(1024 * 1024 * 1024).
maximumWeight(1000000).
weigher(new Weigher<Long, Map<String, List<String>>>(){
public int weigh(Long arg0, Map<String, List<String>> arg1) {
return 1;
}
}).
concurrencyLevel(1).
expireAfterAccess(24, TimeUnit.HOURS);
cache = cacheBuilder.build(cacheLoader);