pub struct TieredCache { /* private fields */ }Expand description
Multi-level cache with automatic promotion.
Checks tiers in order: Memory → Local → (Remote, future). On a hit in a lower tier, promotes the entry to faster tiers.
Implementations§
Source§impl TieredCache
impl TieredCache
Sourcepub fn new(tiers: Vec<(CacheTier, Box<dyn CacheStore>)>) -> Self
pub fn new(tiers: Vec<(CacheTier, Box<dyn CacheStore>)>) -> Self
Create a tiered cache from a list of (tier, store) pairs. Tiers should be ordered fastest-first.
Sourcepub fn memory_and_local(
memory: Box<dyn CacheStore>,
local: Box<dyn CacheStore>,
) -> Self
pub fn memory_and_local( memory: Box<dyn CacheStore>, local: Box<dyn CacheStore>, ) -> Self
Create a two-level cache: Memory + Local.
Trait Implementations§
Source§impl CacheStore for TieredCache
impl CacheStore for TieredCache
fn get(&self, key: &CacheKey) -> Result<Option<Value>>
fn put(&self, key: &CacheKey, value: &Value) -> Result<()>
fn exists(&self, key: &CacheKey) -> Result<bool>
fn remove(&self, key: &CacheKey) -> Result<()>
fn metadata(&self, key: &CacheKey) -> Result<Option<EntryMeta>>
Auto Trait Implementations§
impl Freeze for TieredCache
impl !RefUnwindSafe for TieredCache
impl Send for TieredCache
impl Sync for TieredCache
impl Unpin for TieredCache
impl UnsafeUnpin for TieredCache
impl !UnwindSafe for TieredCache
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