Class ReadCache

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class ReadCache
    extends java.lang.Object
    implements java.io.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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      long count()  
      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 size()  
      • Methods inherited from class java.lang.Object

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

      • ReadCache

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

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

      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.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