@Override public SampleableConcurrentHashMap<String, Getter> createNew(Class arg) { return new SampleableConcurrentHashMap<String, Getter>(maxGetterPerClassCount); } };
/** * 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) { map.purgeStaleEntries(); int mapSize = map.size(); if (mapSize - triggeringEvictionSize >= 0) { for (SampleableConcurrentHashMap.SamplingEntry entry : map.getRandomSamples(mapSize - afterEvictionSize)) { map.remove(entry.getEntryKey()); } } }
@Override public Iterable<NearCacheEvictableSamplingEntry> sample(int sampleCount) { return super.getRandomSamples(sampleCount); } }
@Override public CacheRecord putIfAbsent(Data key, CacheRecord value) { CacheRecord oldRecord = super.putIfAbsent(key, value); if (oldRecord == null && entryCountingEnable) { // New put cacheContext.increaseEntryCount(); } return oldRecord; }
@Override public boolean remove(Object key, Object value) { boolean removed = super.remove(key, value); if (removed && entryCountingEnable) { // Removed cacheContext.decreaseEntryCount(); } return removed; }
int getClassCacheSize() { return getterCache.size(); }
if (nextEntry.key() != null) { final V value = nextEntry.value(); if (isValidForFetching(value, now)) { K key = nextEntry.key(); entries.add(new AbstractMap.SimpleEntry<K, V>(key, value));
@Nullable Getter getGetter(Class clazz, String attributeName) { ConcurrentMap<String, Getter> cache = getterCache.get(clazz); if (cache == null) { return null; } return cache.get(attributeName); }
@Override public void clear() { final int sizeBeforeClear = size(); super.clear(); if (entryCountingEnable) { cacheContext.decreaseEntryCount(sizeBeforeClear); } }
@Override public CacheRecord put(Data key, CacheRecord value) { CacheRecord oldRecord = super.put(key, value); if (oldRecord == null && entryCountingEnable) { // New put cacheContext.increaseEntryCount(); } return oldRecord; }
@Override public Iterable<CacheEvictableSamplingEntry> sample(int sampleCount) { return super.getRandomSamples(sampleCount); } }
@Override public CacheRecord putIfAbsent(Data key, CacheRecord value) { CacheRecord oldRecord = super.putIfAbsent(key, value); if (oldRecord == null && entryCountingEnable) { // New put cacheContext.increaseEntryCount(); } return oldRecord; }
@Override public CacheRecord remove(Object key) { CacheRecord removedRecord = super.remove(key); if (removedRecord != null && entryCountingEnable) { // Removed cacheContext.decreaseEntryCount(); } return removedRecord; }
int getClassCacheSize() { return getterCache.size(); }
if (nextEntry.key() != null) { final V value = nextEntry.value(); if (isValidForFetching(value, now)) { K key = nextEntry.key(); entries.add(new AbstractMap.SimpleEntry<K, V>(key, value));
@Nullable Getter getGetter(Class clazz, String attributeName) { ConcurrentMap<String, Getter> cache = getterCache.get(clazz); if (cache == null) { return null; } return cache.get(attributeName); }
@Override public void clear() { final int sizeBeforeClear = size(); super.clear(); if (entryCountingEnable) { cacheContext.decreaseEntryCount(sizeBeforeClear); } }
@Override public CacheRecord put(Data key, CacheRecord value) { CacheRecord oldRecord = super.put(key, value); if (oldRecord == null && entryCountingEnable) { // New put cacheContext.increaseEntryCount(); } return oldRecord; }
/** * 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) { map.purgeStaleEntries(); int mapSize = map.size(); if (mapSize - triggeringEvictionSize >= 0) { for (SampleableConcurrentHashMap.SamplingEntry entry : map.getRandomSamples(mapSize - afterEvictionSize)) { map.remove(entry.getEntryKey()); } } }