pub struct Cache<E: Storage + Metrics, V: CodecShared>(/* private fields */);Expand description
Implementation of Cache storage.
Mutating functions consume the cache and return it only on success: an error (or a dropped future) destroys the handle.
Implementations§
Source§impl<E: Storage + Metrics, V: CodecShared> Cache<E, V>
impl<E: Storage + Metrics, V: CodecShared> Cache<E, V>
Sourcepub async fn init(context: E, cfg: Config<V::Cfg>) -> Result<Self, Error>
pub async fn init(context: E, cfg: Config<V::Cfg>) -> Result<Self, Error>
Initialize a new Cache instance.
The in-memory index for Cache is populated during this call
by replaying the journal.
Sourcepub async fn get(&self, index: u64) -> Result<Option<V>, Error>
pub async fn get(&self, index: u64) -> Result<Option<V>, Error>
Retrieve an item from the Cache.
Sourcepub fn next_gap(&self, index: u64) -> (Option<u64>, Option<u64>)
pub fn next_gap(&self, index: u64) -> (Option<u64>, Option<u64>)
Retrieve the next gap in the Cache.
Sourcepub fn missing_items(&self, start: u64, max: usize) -> Vec<u64>
pub fn missing_items(&self, start: u64, max: usize) -> Vec<u64>
Returns up to max missing items starting from start.
This method iterates through gaps between existing ranges, collecting missing indices
until either max items are found or there are no more gaps to fill.
Sourcepub async fn prune(self, min: u64) -> Result<Self, Error>
pub async fn prune(self, min: u64) -> Result<Self, Error>
Prune Cache to the provided min.
If this is called with a min lower than the last pruned, nothing will happen.
Sourcepub async fn put(self, index: u64, value: V) -> Result<Self, Error>
pub async fn put(self, index: u64, value: V) -> Result<Self, Error>
Store an item in the Cache.
If the index already exists, put does nothing and returns. A put below the prune floor is satisfied without storing: pruning declared that range obsolete, so nothing is mutated and nothing below the floor is ever readable.
Trait Implementations§
Auto Trait Implementations§
impl<E, V> !RefUnwindSafe for Cache<E, V>
impl<E, V> !UnwindSafe for Cache<E, V>
impl<E, V> Freeze for Cache<E, V>
impl<E, V> Send for Cache<E, V>
impl<E, V> Sync for Cache<E, V>
impl<E, V> Unpin for Cache<E, V>
impl<E, V> UnsafeUnpin for Cache<E, V>where
Box<Inner<E, V>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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