Class ReadCache
java.lang.Object
org.apache.bookkeeper.bookie.storage.ldb.ReadCache
- All Implemented Interfaces:
Closeable,AutoCloseable
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 -
Method Summary
-
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
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
-