pub struct BufferPool { /* private fields */ }Expand description
Thread-safe buffer pool with CLOCK eviction.
Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a buffer pool that may grow to capacity frame slots.
Frames are allocated on demand rather than up front: each frame owns
a full page buffer, so eager allocation costs capacity * 64KB per
open database regardless of use. A process holding many open
databases (the platform gateway keeps an LRU of per user databases)
pays only for pages actually touched.
Sourcepub fn fetch_page(
&self,
page_id: PageId,
pm: &mut PageManager,
) -> MenteResult<Box<Page>>
pub fn fetch_page( &self, page_id: PageId, pm: &mut PageManager, ) -> MenteResult<Box<Page>>
Fetch a page into the pool (loading from disk if necessary).
The page is automatically pinned (pin_count incremented).
Caller must call unpin_page when done.
Sourcepub fn pin_page(&self, page_id: PageId) -> MenteResult<()>
pub fn pin_page(&self, page_id: PageId) -> MenteResult<()>
Increment the pin count of a page already in the pool.
Sourcepub fn unpin_page(&self, page_id: PageId, dirty: bool) -> MenteResult<()>
pub fn unpin_page(&self, page_id: PageId, dirty: bool) -> MenteResult<()>
Decrement pin count and optionally mark the page dirty.
Sourcepub fn invalidate(&self, page_id: PageId)
pub fn invalidate(&self, page_id: PageId)
Drop a page from the pool without flushing, discarding any dirty state.
Used when a page is freed: the on-disk state is already authoritative, so a stale cached copy must never be served or flushed back. A no-op if the page is not cached.
Sourcepub fn update_page(&self, page_id: PageId, page: &Page) -> MenteResult<()>
pub fn update_page(&self, page_id: PageId, page: &Page) -> MenteResult<()>
Replace the cached copy of a page and mark it dirty.
Sourcepub fn flush_page(
&self,
page_id: PageId,
pm: &mut PageManager,
) -> MenteResult<()>
pub fn flush_page( &self, page_id: PageId, pm: &mut PageManager, ) -> MenteResult<()>
Flush a single dirty page to disk.
Sourcepub fn flush_all(&self, pm: &mut PageManager) -> MenteResult<()>
pub fn flush_all(&self, pm: &mut PageManager) -> MenteResult<()>
Flush all dirty pages to disk.