pub trait CacheStore:
Send
+ Sync
+ 'static {
// Required methods
fn get<'a>(&'a self, key: &'a str) -> CacheFuture<'a, Option<CachedValue>>;
fn put(
&self,
key: String,
value: CachedValue,
ttl_ms: u64,
) -> CacheFuture<'_, ()>;
fn remove<'a>(&'a self, key: &'a str) -> CacheFuture<'a, bool>;
// Provided method
fn purge_expired(&self) -> usize { ... }
}Expand description
Pluggable asynchronous response/data cache store (in-memory, Redis, Memcached, etc.).
Required Methods§
Sourcefn get<'a>(&'a self, key: &'a str) -> CacheFuture<'a, Option<CachedValue>>
fn get<'a>(&'a self, key: &'a str) -> CacheFuture<'a, Option<CachedValue>>
Looks up an unexpired CachedValue for key.
§Arguments
&'a self- Shared reference to self.&'a str- Cache key.
§Returns
CacheFuture<'a, Option<CachedValue>>- Cached value when present and unexpired.
Sourcefn put(
&self,
key: String,
value: CachedValue,
ttl_ms: u64,
) -> CacheFuture<'_, ()>
fn put( &self, key: String, value: CachedValue, ttl_ms: u64, ) -> CacheFuture<'_, ()>
Provided Methods§
Sourcefn purge_expired(&self) -> usize
fn purge_expired(&self) -> usize
Evicts expired entries and returns the count removed.
§Returns
usize- Number of expired entries reclaimed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl CacheStore for ShardedMemoryCache
Implements CacheStore for ShardedMemoryCache.