Interface BlockCache

  • All Known Implementing Classes:
    LruBlockCache

    public interface BlockCache
    Block cache interface.
    • Method Detail

      • cacheBlock

        CacheEntry cacheBlock​(String blockName,
                              byte[] buf,
                              boolean inMemory)
        Add block to cache.
        Parameters:
        blockName - Zero-based file block number.
        buf - The block contents wrapped in a ByteBuffer.
        inMemory - Whether block should be treated as in-memory
      • cacheBlock

        CacheEntry cacheBlock​(String blockName,
                              byte[] buf)
        Add block to cache (defaults to not in-memory).
        Parameters:
        blockName - Zero-based file block number.
        buf - The block contents wrapped in a ByteBuffer.
      • getBlock

        CacheEntry getBlock​(String blockName)
        Fetch block from cache.
        Parameters:
        blockName - Block number to fetch.
        Returns:
        Block or null if block is not in the cache.
      • getMaxSize

        long getMaxSize()
        Get the maximum size of this cache.
        Returns:
        max size in bytes
      • getLoadLock

        Lock getLoadLock​(String blockName)
        Return a lock used for loading data not in the cache. Should always return the same lock for the same block name. Can return different locks for different block names. Its ok to return null if locking is not desired.