/** * It works on best effort basis. If multi-threaded calls involved it may evict all elements, but * it's unlikely. */ private void evictMap( SampleableConcurrentHashMap<?, ?> map, int triggeringEvictionSize, int afterEvictionSize) { int mapSize = map.size(); if (mapSize - triggeringEvictionSize >= 0) { for (Map.Entry entry : map.getRandomSamples(mapSize - afterEvictionSize)) { map.remove(entry.getKey()); } } }
int getGetterPerClassCacheSize(Class clazz) { SampleableConcurrentHashMap cacheForClass = getterCache.get(clazz); return cacheForClass != null ? cacheForClass.size() : -1; }