Skip to main content

BackingStore

Trait BackingStore 

Source
pub trait BackingStore {
    type Key: Eq + Hash + Clone;
    type Value: Clone;
    type Error: Debug;

    // Required methods
    fn write(
        &mut self,
        key: &Self::Key,
        value: &Self::Value,
    ) -> Result<(), Self::Error>;
    fn read(&self, key: &Self::Key) -> Result<Option<Self::Value>, Self::Error>;
    fn delete(&mut self, key: &Self::Key) -> Result<(), Self::Error>;
}
Expand description

Abstraction over the origin data store that the cache sits in front of.

Implementations are expected to be synchronous. For async I/O, the caller should provide a blocking adapter.

Required Associated Types§

Source

type Key: Eq + Hash + Clone

The key type.

Source

type Value: Clone

The value type.

Source

type Error: Debug

Error type returned by store operations.

Required Methods§

Source

fn write( &mut self, key: &Self::Key, value: &Self::Value, ) -> Result<(), Self::Error>

Write (key, value) to the backing store.

Source

fn read(&self, key: &Self::Key) -> Result<Option<Self::Value>, Self::Error>

Read the value for key from the backing store (cache miss path).

Source

fn delete(&mut self, key: &Self::Key) -> Result<(), Self::Error>

Delete key from the backing store.

Implementors§