pub struct ClockProCache { /* private fields */ }Expand description
Clock-Pro adaptive page cache
§Algorithm Overview
-
Cold pages: Recently accessed once. These may be promoted to hot if accessed again before eviction (reuse distance < test size).
-
Hot pages: Frequently accessed. Protected from eviction until demoted to cold.
-
Test pages: Ghost entries tracking recently evicted cold pages. If a test page is accessed, it indicates we should increase hot space.
§Adaptive Sizing
The hot/cold ratio adjusts based on access patterns:
- Access to test page → increase hot space (working set growing)
- Cold page eviction without test hit → decrease hot space
Implementations§
Source§impl ClockProCache
impl ClockProCache
Sourcepub fn with_page_size(capacity: usize, page_size: usize) -> Self
pub fn with_page_size(capacity: usize, page_size: usize) -> Self
Create with specific page size
Sourcepub fn insert(&self, page_id: PageId, data: Vec<u8>) -> Arc<CachedPage>
pub fn insert(&self, page_id: PageId, data: Vec<u8>) -> Arc<CachedPage>
Insert a page into cache
Sourcepub fn insert_pinned(&self, page_id: PageId, data: Vec<u8>) -> Arc<CachedPage>
pub fn insert_pinned(&self, page_id: PageId, data: Vec<u8>) -> Arc<CachedPage>
Insert with pinning
Sourcepub fn stats(&self) -> &CacheStats
pub fn stats(&self) -> &CacheStats
Get statistics
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get memory usage in bytes
Auto Trait Implementations§
impl !Freeze for ClockProCache
impl !RefUnwindSafe for ClockProCache
impl !UnwindSafe for ClockProCache
impl Send for ClockProCache
impl Sync for ClockProCache
impl Unpin for ClockProCache
impl UnsafeUnpin for ClockProCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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