pub(crate) trait AsyncLruCacheBackend: Send + Sync {
type Key: Clone + Copy + Debug + PartialEq + Eq + Hash + Send + Sync;
type Value: Send + Sync;
// Required methods
async fn load(&self, key: Self::Key) -> Result<Self::Value>;
async fn flush(&self, key: Self::Key, value: Arc<Self::Value>) -> Result<()>;
unsafe fn evict(&self, key: Self::Key, value: Self::Value);
}
Expand description
Provides loading and flushing for cache entries.
Required Associated Types§
Required Methods§
Sourceasync fn flush(&self, key: Self::Key, value: Arc<Self::Value>) -> Result<()>
async fn flush(&self, key: Self::Key, value: Arc<Self::Value>) -> Result<()>
Flush the given object.
The implementation should itself check whether the object is dirty; flush()
is called for
all evicted cache entries, regardless of whether they actually are dirty or not.
Sourceunsafe fn evict(&self, key: Self::Key, value: Self::Value)
unsafe fn evict(&self, key: Self::Key, value: Self::Value)
Drop the given object without flushing.
The cache owner is invalidating the cache, evicting all objects without flushing them. If dropping the object as-is would cause problems (e.g. because it is verified not to be dirty), those problems need to be resolved here.
§Safety
Depending on the nature of the cache, this operation may be unsafe. Must only be performed if the cache owner requested it and guarantees it is safe.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.