pub struct InProcessCache { /* private fields */ }Expand description
The OSS default single-replica tier: a bounded map with per-entry TTL (jittered), LRU eviction, a value-size bound, and single-flight miss coalescing via per-key locks.
Implementations§
Source§impl InProcessCache
impl InProcessCache
pub fn new(capacity: usize, max_value_bytes: usize) -> Self
Sourcepub fn get_or_compute<F, E>(
&self,
namespace: &str,
key: &str,
ttl: Option<Duration>,
compute: F,
) -> Result<Vec<u8>, E>
pub fn get_or_compute<F, E>( &self, namespace: &str, key: &str, ttl: Option<Duration>, compute: F, ) -> Result<Vec<u8>, E>
Single-flight compute-through: return a cached value, or compute it exactly once even under concurrent misses for the same key. A computed ERROR is propagated but NEVER cached.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl CacheBackend for InProcessCache
impl CacheBackend for InProcessCache
Auto Trait Implementations§
impl !Freeze for InProcessCache
impl RefUnwindSafe for InProcessCache
impl Send for InProcessCache
impl Sync for InProcessCache
impl Unpin for InProcessCache
impl UnsafeUnpin for InProcessCache
impl UnwindSafe for InProcessCache
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