@ThreadSafe public class LocalCacheManager extends Object implements CacheManager
CacheManager.Factory, CacheManager.State
Modifier and Type | Method and Description |
---|---|
boolean |
append(PageId pageId,
int appendAt,
byte[] page,
CacheContext cacheContext) |
void |
close() |
static LocalCacheManager |
create(CacheManagerOptions options,
PageMetaStore pageMetaStore) |
boolean |
delete(PageId pageId)
Deletes a page from the cache.
|
int |
get(PageId pageId,
int pageOffset,
int bytesToRead,
PageReadTargetBuffer buffer,
CacheContext cacheContext)
Reads a part of a page if the queried page is found in the cache, stores the result in buffer.
|
List<PageId> |
getCachedPageIdsByFileId(String fileId,
long fileLength)
Get page ids by the given file id.
|
int |
getPageLockId(PageId pageId) |
void |
invalidate(java.util.function.Predicate<PageInfo> predicate)
Invalidate the pages that match the given predicate.
|
boolean |
put(PageId pageId,
ByteBuffer page,
CacheContext cacheContext)
Puts a page into the cache manager with scope and quota respected.
|
CacheManager.State |
state() |
public static LocalCacheManager create(CacheManagerOptions options, PageMetaStore pageMetaStore) throws IOException
options
- the options of local cache managerpageMetaStore
- the metadata store for local cacheLocalCacheManager
IOException
public int getPageLockId(PageId pageId)
pageId
- page identifierpublic boolean put(PageId pageId, ByteBuffer page, CacheContext cacheContext)
CacheManager
put
in interface CacheManager
pageId
- page identifierpage
- page datacacheContext
- cache related contextpublic int get(PageId pageId, int pageOffset, int bytesToRead, PageReadTargetBuffer buffer, CacheContext cacheContext)
CacheManager
get
in interface CacheManager
pageId
- page identifierpageOffset
- offset into the pagebytesToRead
- number of bytes to read in this pagebuffer
- destination buffer to writecacheContext
- cache related contextpublic boolean delete(PageId pageId)
CacheManager
delete
in interface CacheManager
pageId
- page identifierpublic CacheManager.State state()
state
in interface CacheManager
public boolean append(PageId pageId, int appendAt, byte[] page, CacheContext cacheContext)
append
in interface CacheManager
public List<PageId> getCachedPageIdsByFileId(String fileId, long fileLength)
CacheManager
getCachedPageIdsByFileId
in interface CacheManager
fileId
- file identifierfileLength
- file length (this will not be needed after we have per-file metadata)public void invalidate(java.util.function.Predicate<PageInfo> predicate)
CacheManager
invalidate
in interface CacheManager
public void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2023. All Rights Reserved.