@Override
  public void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory) {

    // Some data blocks will not put into BlockCache when eviction rate too much.
    // It is good for performance
    // (see details: https://issues.apache.org/jira/browse/HBASE-23887)
    // How to calculate it can find inside EvictionThread class.
    if (cacheDataBlockPercent != 100 && buf.getBlockType().isData()) {
      // It works like filter - blocks which two last digits of offset
      // more than we calculate in Eviction Thread will not put into BlockCache
      if (cacheKey.getOffset() % 100 >= cacheDataBlockPercent) {
        return;
      }
    }

    if (buf.heapSize() > maxBlockSize) {
      // If there are a lot of blocks that are too
      // big this can make the logs way too noisy.
      // So we log 2%
      if (stats.failInsert() % 50 == 0) {
        LOG.warn("Trying to cache too large a block " + cacheKey.getHfileName() + " @ "
          + cacheKey.getOffset() + " is " + buf.heapSize() + " which is larger than "
          + maxBlockSize);
      }
      return;
    }

    LruCachedBlock cb = map.get(cacheKey);
    if (cb != null && !BlockCacheUtil.shouldReplaceExistingCacheBlock(this, cacheKey, buf)) {
      return;
    }
    long currentSize = size.get();
    long currentAcceptableSize = acceptableSize();
    long hardLimitSize = (long) (hardCapacityLimitFactor * currentAcceptableSize);
    if (currentSize >= hardLimitSize) {
      stats.failInsert();
      if (LOG.isTraceEnabled()) {
        LOG.trace("LruAdaptiveBlockCache current size " + StringUtils.byteDesc(currentSize)
          + " has exceeded acceptable size " + StringUtils.byteDesc(currentAcceptableSize) + "."
          + " The hard limit size is " + StringUtils.byteDesc(hardLimitSize)
          + ", failed to put cacheKey:" + cacheKey + " into LruAdaptiveBlockCache.");
      }
      if (!evictionInProgress) {
        runEviction();
      }
      return;
    }
    // Ensure that the block is an heap one.
    buf = asReferencedHeapBlock(buf);
    cb = new LruCachedBlock(cacheKey, buf, count.incrementAndGet(), inMemory);
    long newSize = updateSizeMetrics(cb, false);
    map.put(cacheKey, cb);
    long val = elements.incrementAndGet();
    if (buf.getBlockType().isData()) {
      dataBlockElements.increment();
    }
    if (LOG.isTraceEnabled()) {
      long size = map.size();
      assertCounterSanity(size, val);
    }
    if (newSize > currentAcceptableSize && !evictionInProgress) {
      runEviction();
    }
  }
Cache the block with the specified name and buffer.
<p>
It is assumed this will NOT be called on an already cached block. In rare cases (HBASE-8547)
this can happen, for which we compare the buffer contents.
@param cacheKey block's cache key
@param buf      block buffer
@param inMemory if block is in-memory
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruAdaptiveBlockCache.java