pub struct WriteThroughCache<S, C> { /* private fields */ }Expand description
A cache adapter that propagates writes to a backing KvStore immediately.
put(k, v)→ writes to both the cache and the store.get(k)→ returns from cache if present; on miss, fetches from the store, populates the cache, and returns the value.remove(k)→ removes from both cache and store.
§Type parameters
S: aKvStoreimplementor.C: aCache<Vec<u8>, Vec<u8>>implementor.
Implementations§
Source§impl<S, C> WriteThroughCache<S, C>
impl<S, C> WriteThroughCache<S, C>
Sourcepub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>, StoreError>
pub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>, StoreError>
Look up key: cache first, then store on miss.
On a store hit the value is populated back into the cache.
Sourcepub fn put(&mut self, key: Vec<u8>, value: Vec<u8>) -> Result<(), StoreError>
pub fn put(&mut self, key: Vec<u8>, value: Vec<u8>) -> Result<(), StoreError>
Insert key → value into both cache and store.
Auto Trait Implementations§
impl<S, C> Freeze for WriteThroughCache<S, C>
impl<S, C> RefUnwindSafe for WriteThroughCache<S, C>where
S: RefUnwindSafe,
C: RefUnwindSafe,
impl<S, C> Send for WriteThroughCache<S, C>
impl<S, C> Sync for WriteThroughCache<S, C>
impl<S, C> Unpin for WriteThroughCache<S, C>
impl<S, C> UnsafeUnpin for WriteThroughCache<S, C>where
S: UnsafeUnpin,
C: UnsafeUnpin,
impl<S, C> UnwindSafe for WriteThroughCache<S, C>where
S: UnwindSafe,
C: UnwindSafe,
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