pub struct PageCacheShard { /* private fields */ }Expand description
SIEVE-based page cache
Thread-safe page cache using the SIEVE eviction algorithm.
Implementations§
Source§impl PageCacheShard
impl PageCacheShard
Sourcepub fn with_default_capacity() -> Self
pub fn with_default_capacity() -> Self
Create a page cache with default capacity
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics
Sourcepub fn get(&self, page_id: u32) -> Option<Page>
pub fn get(&self, page_id: u32) -> Option<Page>
Get a page from cache
Returns None if page is not in cache (cache miss). On hit, marks the page as visited (SIEVE).
Sourcepub fn insert(&self, page_id: u32, page: Page) -> Option<Page>
pub fn insert(&self, page_id: u32, page: Page) -> Option<Page>
Insert a page into cache
May trigger eviction if cache is full. Returns the evicted page (if dirty) that needs to be written back.
Sourcepub fn mark_dirty(&self, page_id: u32)
pub fn mark_dirty(&self, page_id: u32)
Mark a page as dirty
Sourcepub fn mark_clean(&self, page_id: u32)
pub fn mark_clean(&self, page_id: u32)
Mark a page as clean
Sourcepub fn flush_dirty(&self) -> Vec<(u32, Page)>
pub fn flush_dirty(&self) -> Vec<(u32, Page)>
Flush all dirty pages
Returns an iterator of (page_id, page) for dirty pages.
Sourcepub fn flush_some_dirty(&self, max: usize) -> Vec<(u32, Page)>
pub fn flush_some_dirty(&self, max: usize) -> Vec<(u32, Page)>
Bounded counterpart of flush_dirty used by the background
writer. Snapshots up to max dirty pages, marks them clean,
and returns the (page_id, page) pairs for the caller to
persist via the pager. Clamps to the current dirty set —
returning fewer than max simply means we’re caught up.
Sourcepub fn dirty_count(&self) -> usize
pub fn dirty_count(&self) -> usize
Count dirty pages currently in the cache. Used by the background writer to compute an adaptive flush budget.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PageCacheShard
impl RefUnwindSafe for PageCacheShard
impl Send for PageCacheShard
impl Sync for PageCacheShard
impl Unpin for PageCacheShard
impl UnsafeUnpin for PageCacheShard
impl UnwindSafe for PageCacheShard
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
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request