pub struct MemoryBackend<K, V> { /* private fields */ }Expand description
An in-memory cache backend with an entry-count capacity.
Clones share the same storage. Independently constructed instances are
isolated, including for CacheBackend::clear.
Implementations§
Trait Implementations§
Source§impl<K, V> CacheBackend<K, V> for MemoryBackend<K, V>
impl<K, V> CacheBackend<K, V> for MemoryBackend<K, V>
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = KapeResult<Option<CacheEntry<V>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = KapeResult<Option<CacheEntry<V>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Queries one key.
Source§fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
value: Arc<V>,
ttl: i64,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
value: Arc<V>,
ttl: i64,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stores or immediately invalidates one key using a millisecond TTL.
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 K,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Removes one key.
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = KapeResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clears entries owned by this backend instance.
Source§fn get_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 K],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<CacheEntry<V>>>, KapeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn get_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 K],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<CacheEntry<V>>>, KapeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Queries multiple keys while preserving input order and duplicates.
Source§fn set_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
items: &'life1 [SetItem<&'life2 K, V>],
) -> Pin<Box<dyn Future<Output = Result<(), KapeError>> + Send + 'async_trait>>
fn set_many<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, items: &'life1 [SetItem<&'life2 K, V>], ) -> Pin<Box<dyn Future<Output = Result<(), KapeError>> + Send + 'async_trait>>
Writes multiple uniquely keyed items in input order.
Source§fn remove_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 K],
) -> Pin<Box<dyn Future<Output = Result<(), KapeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn remove_many<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 K],
) -> Pin<Box<dyn Future<Output = Result<(), KapeError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Removes multiple keys in input order.
Auto Trait Implementations§
impl<K, V> !RefUnwindSafe for MemoryBackend<K, V>
impl<K, V> !UnwindSafe for MemoryBackend<K, V>
impl<K, V> Freeze for MemoryBackend<K, V>
impl<K, V> Send for MemoryBackend<K, V>
impl<K, V> Sync for MemoryBackend<K, V>
impl<K, V> Unpin for MemoryBackend<K, V>
impl<K, V> UnsafeUnpin for MemoryBackend<K, V>where
Cache<K, MemoryEntry<V>>: UnsafeUnpin,
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