/** * Cache the block with the specified name and buffer. * @param cacheKey block's cache key * @param cachedItem block buffer * @param inMemory if block is in-memory */ @Override public void cacheBlock(BlockCacheKey cacheKey, Cacheable cachedItem, boolean inMemory) { cacheBlockWithWait(cacheKey, cachedItem, inMemory, wait_when_cache); }
/** * Cache the block with the specified name and buffer. * @param cacheKey block's cache key * @param cachedItem block buffer * @param inMemory if block is in-memory * @param cacheDataInL1 */ @Override public void cacheBlock(BlockCacheKey cacheKey, Cacheable cachedItem, boolean inMemory, final boolean cacheDataInL1) { cacheBlockWithWait(cacheKey, cachedItem, inMemory, wait_when_cache); }
/** * Evict the block, and it will be cached by the victim handler if exists && * block may be read again later * @param block * @param evictedByEvictionProcess true if the given block is evicted by * EvictionThread * @return the heap size of evicted block */ protected long evictBlock(LruCachedBlock block, boolean evictedByEvictionProcess) { map.remove(block.getCacheKey()); updateSizeMetrics(block, true); long val = elements.decrementAndGet(); if (LOG.isTraceEnabled()) { long size = map.size(); assertCounterSanity(size, val); } stats.evicted(block.getCachedTime(), block.getCacheKey().isPrimary()); if (evictedByEvictionProcess && victimHandler != null) { if (victimHandler instanceof BucketCache) { boolean wait = getCurrentSize() < acceptableSize(); boolean inMemory = block.getPriority() == BlockPriority.MEMORY; ((BucketCache)victimHandler).cacheBlockWithWait(block.getCacheKey(), block.getBuffer(), inMemory, wait); } else { victimHandler.cacheBlock(block.getCacheKey(), block.getBuffer()); } } return block.heapSize(); }