pub trait ObjectCache<K: Key, V: Value>: Send + Sync {
// Required methods
fn lookup_or_reserve<'a>(&'a self, key: &K) -> ObjectCacheResult<'a, V>;
fn is_cacheable(&self, key: &K) -> bool;
fn invalidate(&self, key: &K, value: Option<V>);
fn clear(&self);
// Provided method
fn len(&self) -> usize { ... }
}Required Methods§
Sourcefn lookup_or_reserve<'a>(&'a self, key: &K) -> ObjectCacheResult<'a, V>
fn lookup_or_reserve<'a>(&'a self, key: &K) -> ObjectCacheResult<'a, V>
Looks up a key in the cache and may return a cached value for it. See ObjectCacheResult.
Sourcefn is_cacheable(&self, key: &K) -> bool
fn is_cacheable(&self, key: &K) -> bool
Returns whether the key is cacheable. This is used by clients to avoid cloning keys and
values when calling invalidate would do nothing.
Must be consistent with lookup_or_reserve returning NoCache.
Sourcefn invalidate(&self, key: &K, value: Option<V>)
fn invalidate(&self, key: &K, value: Option<V>)
Removes key from cache if value is None, invalidates the results of placeholders that have
not been resolved. When value is provided then the value may be inserted, and may replace
an existing value.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".