pub struct PageCache { /* private fields */ }Expand description
Bounded, MVCC-safe page cache with frequency-aware CLOCK eviction and an optional persistent backing directory.
Implementations§
Source§impl PageCache
impl PageCache
pub fn new(capacity_bytes: u64) -> Self
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Cumulative hit/miss counts since construction (or the last
reset_stats). Cheap (Relaxed atomic loads).
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Zero the hit/miss counters (e.g. to measure a single query’s locality).
Sourcepub fn with_persistence(self, dir: PathBuf) -> Self
pub fn with_persistence(self, dir: PathBuf) -> Self
Enable persistence: load any cached pages from <dir> and spill future
evictions/inserts there. Files are raw page bytes (ciphertext when the
table is encrypted).
Sourcepub fn insert(&mut self, page: CachedPage)
pub fn insert(&mut self, page: CachedPage)
Insert a page (replaces any entry with the same key). Spills to the persistent backing directory when enabled.
Sourcepub fn get(
&mut self,
content_hash: &[u8; 32],
snapshot: Snapshot,
) -> Option<Bytes>
pub fn get( &mut self, content_hash: &[u8; 32], snapshot: Snapshot, ) -> Option<Bytes>
Fetch the page visible to snapshot (the entry’s committed epoch must be
<= snapshot.epoch), promoting its frequency. O(1).
Sourcepub fn try_get(
&self,
content_hash: &[u8; 32],
snapshot: Snapshot,
) -> Option<Bytes>
pub fn try_get( &self, content_hash: &[u8; 32], snapshot: Snapshot, ) -> Option<Bytes>
Non-blocking probe used by the parallel (rayon) read path: returns a hit
without contending on a write lock when one is held. Some on hit;
None on miss (or if the value is not visible to snapshot). The
caller treats any None as “fall through to disk”.
pub fn used_bytes(&self) -> u64
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn flush_to_disk(&self)
pub fn flush_to_disk(&self)
Flush all live entries to the persistent backing dir (best-effort).
Auto Trait Implementations§
impl !Freeze for PageCache
impl RefUnwindSafe for PageCache
impl Send for PageCache
impl Sync for PageCache
impl Unpin for PageCache
impl UnsafeUnpin for PageCache
impl UnwindSafe for PageCache
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> 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 more