pub struct MemoryReconstructionCache { /* private fields */ }Expand description
Bounded in-memory reconstruction cache adapter.
Implementations§
Source§impl MemoryReconstructionCache
impl MemoryReconstructionCache
Sourcepub fn new(ttl_seconds: NonZeroU64, max_entries: NonZeroUsize) -> Self
pub fn new(ttl_seconds: NonZeroU64, max_entries: NonZeroUsize) -> Self
Creates a bounded in-memory reconstruction cache.
Sourcepub async fn get_or_load<F, Fut>(
&self,
key: &ReconstructionCacheKey,
loader: F,
) -> Result<Option<Vec<u8>>, ReconstructionCacheError>
pub async fn get_or_load<F, Fut>( &self, key: &ReconstructionCacheKey, loader: F, ) -> Result<Option<Vec<u8>>, ReconstructionCacheError>
Returns the cached value for key, or computes it with loader.
Concurrent calls for the same key are deduplicated — only one caller runs the loader; the rest await the result.
§Errors
Returns ReconstructionCacheError when the loader fails or the
underlying cache operation encounters an error.
Trait Implementations§
Source§impl AsyncReconstructionCache for MemoryReconstructionCache
impl AsyncReconstructionCache for MemoryReconstructionCache
Source§fn ready(&self) -> ReconstructionCacheFuture<'_, ()>
fn ready(&self) -> ReconstructionCacheFuture<'_, ()>
Verifies that the adapter is configured correctly and can serve requests.
Source§fn get<'operation>(
&'operation self,
key: &'operation ReconstructionCacheKey,
) -> ReconstructionCacheFuture<'operation, Option<Vec<u8>>>
fn get<'operation>( &'operation self, key: &'operation ReconstructionCacheKey, ) -> ReconstructionCacheFuture<'operation, Option<Vec<u8>>>
Loads one cached reconstruction payload.
Source§fn put<'operation>(
&'operation self,
key: &'operation ReconstructionCacheKey,
payload: &'operation [u8],
) -> ReconstructionCacheFuture<'operation, ()>
fn put<'operation>( &'operation self, key: &'operation ReconstructionCacheKey, payload: &'operation [u8], ) -> ReconstructionCacheFuture<'operation, ()>
Stores one reconstruction payload.
Source§fn delete<'operation>(
&'operation self,
key: &'operation ReconstructionCacheKey,
) -> ReconstructionCacheFuture<'operation, bool>
fn delete<'operation>( &'operation self, key: &'operation ReconstructionCacheKey, ) -> ReconstructionCacheFuture<'operation, bool>
Deletes one cached reconstruction payload.
Source§impl Clone for MemoryReconstructionCache
impl Clone for MemoryReconstructionCache
Source§fn clone(&self) -> MemoryReconstructionCache
fn clone(&self) -> MemoryReconstructionCache
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for MemoryReconstructionCache
impl !UnwindSafe for MemoryReconstructionCache
impl Freeze for MemoryReconstructionCache
impl Send for MemoryReconstructionCache
impl Sync for MemoryReconstructionCache
impl Unpin for MemoryReconstructionCache
impl UnsafeUnpin for MemoryReconstructionCache
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