pub struct DiskCache { /* private fields */ }Expand description
Write-through disk cache wrapping a remote PageStore.
The local cache is a LocalPageStore on fast storage (NVMe).
Pages are cached on first read and updated on every write.
Implementations§
Source§impl DiskCache
impl DiskCache
Sourcepub fn new(
cache_dir: impl AsRef<Path>,
remote: Box<dyn PageStore>,
) -> KyuResult<Self>
pub fn new( cache_dir: impl AsRef<Path>, remote: Box<dyn PageStore>, ) -> KyuResult<Self>
Create a new disk cache.
cache_dir: local directory for cached pages (should be on fast storage)remote: the underlying remote page store (e.g. S3)
Sourcepub fn cached_count(&self) -> usize
pub fn cached_count(&self) -> usize
Number of pages currently in the local cache.
Trait Implementations§
Source§impl PageStore for DiskCache
impl PageStore for DiskCache
Source§fn read_page(&self, page_id: PageId, buf: &mut [u8]) -> KyuResult<()>
fn read_page(&self, page_id: PageId, buf: &mut [u8]) -> KyuResult<()>
Read a page from storage into the given buffer.
The buffer must be exactly PAGE_SIZE bytes.
Source§fn write_page(&self, page_id: PageId, buf: &[u8]) -> KyuResult<()>
fn write_page(&self, page_id: PageId, buf: &[u8]) -> KyuResult<()>
Write a page from the given buffer to storage.
The buffer must be exactly PAGE_SIZE bytes.
Auto Trait Implementations§
impl !Freeze for DiskCache
impl !RefUnwindSafe for DiskCache
impl Send for DiskCache
impl Sync for DiskCache
impl Unpin for DiskCache
impl UnsafeUnpin for DiskCache
impl !UnwindSafe for DiskCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.