pub trait LocalStore: Send + 'static {
// Required methods
fn get(&mut self, key: &str, now_ms: i64) -> Result<LocalRead, BoxError>;
fn put(
&mut self,
key: String,
entry: LocalEntry,
) -> Result<Option<LocalEntry>, BoxError>;
}Expand description
Process-local storage for one cache instance.
The default LruLocalStore evicts the least recently used entry at
capacity regardless of its remaining TTL, checks expiry lazily on read
against whole elapsed milliseconds, promotes on read and write, and never
renews a TTL on read. Implementations must preserve those rules.
Required Methods§
Sourcefn get(&mut self, key: &str, now_ms: i64) -> Result<LocalRead, BoxError>
fn get(&mut self, key: &str, now_ms: i64) -> Result<LocalRead, BoxError>
Read one key. A live entry is promoted and returned; an expired entry is removed without promotion and handed back so the cache can drop it outside its lock.
Sourcefn put(
&mut self,
key: String,
entry: LocalEntry,
) -> Result<Option<LocalEntry>, BoxError>
fn put( &mut self, key: String, entry: LocalEntry, ) -> Result<Option<LocalEntry>, BoxError>
Insert or replace an entry, promoting it and evicting at capacity. Returns the displaced entry (the replaced value or the evicted tail), which the cache drops outside its lock.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".