Skip to main content

PageCache

Struct PageCache 

Source
pub struct PageCache<K, V, W = NoOpWriter>
where K: Clone + Eq + Hash, V: Clone, W: PageWriter<K, V>,
{ /* private fields */ }
Expand description

SIEVE Page Cache

Implementations§

Source§

impl<K, V> PageCache<K, V>
where K: Clone + Eq + Hash, V: Clone,

Source

pub fn new(config: CacheConfig) -> PageCache<K, V>

Create new cache with default writer

Source

pub fn with_capacity(capacity: usize) -> PageCache<K, V>

Create with specific capacity

Source§

impl<K, V, W> PageCache<K, V, W>
where K: Clone + Eq + Hash, V: Clone, W: PageWriter<K, V>,

Source

pub fn with_writer(config: CacheConfig, writer: W) -> PageCache<K, V, W>

Create new cache with custom writer

Source

pub fn get_with(&self, key: &K, strategy: BufferAccessStrategy) -> Option<V>

Strategy-aware get.

Normal behaves exactly like PageCache::get. Non-Normal strategies look in the main pool first (a hit is a free win), then fall through to the strategy’s dedicated ring buffer. Hits in the ring do NOT promote the page into the main pool — that is the whole point of the strategy: keep scans out of the hot working set.

Source

pub fn insert_with( &self, key: K, value: V, strategy: BufferAccessStrategy, ) -> Option<(K, V)>

Strategy-aware insert.

Normal behaves exactly like PageCache::insert. Non-Normal strategies route the write into the dedicated ring instead of the main pool. The ring’s eviction return is propagated up so callers (the pager) can flush dirty pages through the double-write buffer.

Source

pub fn clear_strategy_rings(&self)

Drop every strategy ring. Used by tests and by post-checkpoint cleanup.

Source

pub fn get(&self, key: &K) -> Option<V>

Get an entry from cache

Source

pub fn contains(&self, key: &K) -> bool

Check if key exists in cache

Source

pub fn insert(&self, key: K, value: V) -> Option<V>

Insert an entry into cache

Source

pub fn remove(&self, key: &K) -> Option<V>

Remove an entry from cache

Source

pub fn pin(&self, key: &K) -> bool

Pin a page (prevent eviction)

Source

pub fn unpin(&self, key: &K) -> bool

Unpin a page

Source

pub fn mark_dirty(&self, key: &K) -> bool

Mark a page as dirty

Source

pub fn flush(&self) -> Result<usize, Error>

Flush all dirty pages

Source

pub fn clear(&self)

Clear all entries

Source

pub fn len(&self) -> usize

Get current entry count

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

pub fn capacity(&self) -> usize

Get capacity

Source

pub fn stats(&self) -> CacheStats

Get statistics

Source

pub fn config(&self) -> &CacheConfig

Get configuration

Source

pub fn keys(&self) -> Vec<K>

Get all cached keys

Source

pub fn dirty_count(&self) -> usize

Get dirty page count

Auto Trait Implementations§

§

impl<K, V, W = NoOpWriter> !Freeze for PageCache<K, V, W>

§

impl<K, V, W> RefUnwindSafe for PageCache<K, V, W>
where W: RefUnwindSafe,

§

impl<K, V, W> Send for PageCache<K, V, W>
where K: Send + Sync, V: Sync + Send,

§

impl<K, V, W> Sync for PageCache<K, V, W>
where K: Send + Sync, V: Sync + Send,

§

impl<K, V, W> Unpin for PageCache<K, V, W>
where W: Unpin, K: Unpin,

§

impl<K, V, W> UnsafeUnpin for PageCache<K, V, W>
where W: UnsafeUnpin,

§

impl<K, V, W> UnwindSafe for PageCache<K, V, W>
where W: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more