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.