BufferPool

Struct BufferPool 

Source
pub struct BufferPool { /* private fields */ }
Expand description

LRU buffer pool for caching pages in memory

Implementations§

Source§

impl BufferPool

Source

pub fn new(page_manager: Arc<PageManager>, capacity: usize) -> Self

Create a new buffer pool with the specified capacity

§Arguments
  • page_manager - Page manager for disk I/O
  • capacity - Maximum number of pages to cache (default: 1000 = ~4MB)
Source

pub fn get_page(&self, page_id: PageId) -> Result<Page, StorageError>

Get a page from the cache or load from disk

§Arguments
  • page_id - ID of the page to retrieve
§Returns

The requested page, either from cache or loaded from disk

Source

pub fn put_page(&self, page: Page) -> Result<(), StorageError>

Put a page into the cache

§Arguments
  • page - The page to cache
Source

pub fn flush_dirty(&self) -> Result<(), StorageError>

Flush all dirty pages to disk

Source

pub fn evict(&self, page_id: PageId) -> Result<(), StorageError>

Manually evict a page from the cache

§Arguments
  • page_id - ID of the page to evict
Source

pub fn capacity(&self) -> usize

Get the current capacity of the buffer pool

Source

pub fn size(&self) -> Result<usize, StorageError>

Get the current number of pages in the cache

Source

pub fn stats(&self) -> &BufferPoolStats

Get statistics for the buffer pool

Trait Implementations§

Source§

impl Debug for BufferPool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V