pub struct BufferPool { /* private fields */ }Expand description
Buffer pool: caches decrypted pages in memory with SIEVE eviction.
Keyed by physical disk offset (not logical page_id) because under CoW/MVCC the same logical page_id can exist at different disk locations.
Invariants:
- HMAC is verified BEFORE decryption on every page fetch (cache miss).
- Dirty pages are PINNED and never evictable until commit.
- Transaction size is bounded by buffer pool capacity.
Implementations§
Source§impl BufferPool
impl BufferPool
pub fn new(capacity: usize) -> Self
Sourcepub fn fetch(
&mut self,
io: &dyn PageIO,
page_id: PageId,
dek: &[u8; 32],
mac_key: &[u8; 32],
encryption_epoch: u32,
) -> Result<&Page>
pub fn fetch( &mut self, io: &dyn PageIO, page_id: PageId, dek: &[u8; 32], mac_key: &[u8; 32], encryption_epoch: u32, ) -> Result<&Page>
Fetch a page by page_id. Reads from cache or disk.
On cache miss: reads from disk, verifies HMAC BEFORE decrypting, verifies xxHash64 checksum after decrypting.
pub fn fetch_mut( &mut self, io: &dyn PageIO, page_id: PageId, dek: &[u8; 32], mac_key: &[u8; 32], encryption_epoch: u32, ) -> Result<&mut Page>
Sourcepub fn insert_new(&mut self, page_id: PageId, page: Page) -> Result<()>
pub fn insert_new(&mut self, page_id: PageId, page: Page) -> Result<()>
Insert a newly allocated page. Marks it dirty immediately.
pub fn mark_dirty(&mut self, page_id: PageId)
Sourcepub fn flush_dirty(
&mut self,
io: &dyn PageIO,
dek: &[u8; 32],
mac_key: &[u8; 32],
encryption_epoch: u32,
) -> Result<()>
pub fn flush_dirty( &mut self, io: &dyn PageIO, dek: &[u8; 32], mac_key: &[u8; 32], encryption_epoch: u32, ) -> Result<()>
Flush all dirty pages to disk: encrypt + compute MAC + write. Clears dirty flags after successful flush.
Sourcepub fn discard_dirty(&mut self)
pub fn discard_dirty(&mut self)
Discard all dirty pages (on transaction abort). Removes dirty entries from the cache.
pub fn get_cached(&mut self, page_id: PageId) -> Option<Arc<Page>>
pub fn insert_if_absent(&mut self, page_id: PageId, page: Arc<Page>)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn dirty_count(&self) -> usize
pub fn capacity(&self) -> usize
pub fn is_cached(&self, page_id: PageId) -> bool
pub fn invalidate(&mut self, page_id: PageId)
pub fn clear(&mut self)
Auto Trait Implementations§
impl Freeze for BufferPool
impl RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnsafeUnpin for BufferPool
impl UnwindSafe for BufferPool
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