pub struct BoundedMemoryBackend { /* private fields */ }Expand description
A byte-weighted, sharded, in-memory RangeCacheBackend bounded to a fixed
capacity, built on the standalone foyer-memory crate’s Cache – not the
umbrella foyer crate (which FoyerBackend uses via HybridCache, and
which transitively pulls in a disk-backed storage engine). foyer-memory
is the same in-memory engine HybridCache uses internally for its RAM
tier, so this reuses that eviction implementation without the disk-IO
dependencies, via LfuConfig rather than FoyerBackend’s LruConfig.
Used as the shared RAM budget backing the in-process L1 cache
(l1_store.rs).
Implementations§
Trait Implementations§
Source§impl RangeCacheBackend for BoundedMemoryBackend
impl RangeCacheBackend for BoundedMemoryBackend
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
_expected_len: u64,
) -> Pin<Box<dyn Future<Output = Option<Bytes>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
BoundedMemoryBackend: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
_expected_len: u64,
) -> Pin<Box<dyn Future<Output = Option<Bytes>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
BoundedMemoryBackend: 'async_trait,
expected_len is the exact length the caller will accept for key.
A backend MUST NOT copy a value whose length differs into any faster
tier it maintains (the promotion gate) and MUST treat such a value as
a miss. Single-tier backends accept and ignore the parameter.fn put<'life0, 'async_trait>(
&'life0 self,
key: String,
value: Bytes,
_hint: FillHint,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
BoundedMemoryBackend: 'async_trait,
Source§fn disk_stats(&self) -> Option<BackendDiskStats>
fn disk_stats(&self) -> Option<BackendDiskStats>
Disk write-path counters, for the saturation monitor’s per-second
gauges. Defaulted to
None so backends without a disk tier (e.g.
MemoryBackend) need no override.Source§fn ram_usage_bytes(&self) -> Option<usize>
fn ram_usage_bytes(&self) -> Option<usize>
Accounted RAM-tier byte usage, for the saturation monitor’s residency
gauge.
None for backends with no RAM tier accounting (e.g.
MemoryBackend). Divergence between this and process RSS is the
signature of a cached value pinning more than its accounted weight.Source§fn ram_entries(&self) -> Option<usize>
fn ram_entries(&self) -> Option<usize>
Accounted RAM-tier entry count, the entry-count sibling to
ram_usage_bytes. None for backends with no RAM tier accounting
(e.g. MemoryBackend).Auto Trait Implementations§
impl Freeze for BoundedMemoryBackend
impl !RefUnwindSafe for BoundedMemoryBackend
impl Send for BoundedMemoryBackend
impl Sync for BoundedMemoryBackend
impl Unpin for BoundedMemoryBackend
impl UnsafeUnpin for BoundedMemoryBackend
impl !UnwindSafe for BoundedMemoryBackend
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<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
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].