Class ReadCache

java.lang.Object
org.apache.bookkeeper.bookie.storage.ldb.ReadCache
All Implemented Interfaces:
Closeable, AutoCloseable

public class ReadCache extends Object implements Closeable
Read cache implementation.

Uses the specified amount of memory and pairs it with a hashmap.

The memory is split in multiple segments that are used in a ring-buffer fashion. When the read cache is full, the oldest segment is cleared and rotated to make space for new entries to be added to the read cache.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ReadCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize)
     
    ReadCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize, int maxSegmentSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    long
     
    io.netty.buffer.ByteBuf
    get(long ledgerId, long entryId)
     
    boolean
    hasEntry(long ledgerId, long entryId)
     
    void
    put(long ledgerId, long entryId, io.netty.buffer.ByteBuf entry)
     
    long
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ReadCache

      public ReadCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize)
    • ReadCache

      public ReadCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize, int maxSegmentSize)
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • put

      public void put(long ledgerId, long entryId, io.netty.buffer.ByteBuf entry)
    • get

      public io.netty.buffer.ByteBuf get(long ledgerId, long entryId)
    • hasEntry

      public boolean hasEntry(long ledgerId, long entryId)
    • size

      public long size()
      Returns:
      the total size of cached entries
    • count

      public long count()
      Returns:
      the total number of cached entries