[][src]Struct futures_cache::Cache

pub struct Cache { /* fields omitted */ }

Primary cache abstraction.

Can be cheaply cloned and namespaced.

Methods

impl Cache[src]

pub fn load(db: Arc<Tree>) -> Result<Cache, Error>[src]

Load the cache from the database.

pub fn delete_with_ns<N, K>(&self, ns: Option<&N>, key: &K) -> Result<(), Error> where
    N: Serialize,
    K: Serialize
[src]

Delete the given key from the specified namespace.

pub fn list_json(&self) -> Result<Vec<JsonEntry>, Error>[src]

List all cache entries as JSON.

pub fn namespaced<N>(&self, ns: &N) -> Result<Self, Error> where
    N: Serialize
[src]

Create a namespaced cache.

The namespace must be unique to avoid conflicts.

Each call to this functions will return its own queue for resolving futures.

pub fn insert<K, T>(
    &self,
    key: K,
    age: Duration,
    value: &T
) -> Result<(), Error> where
    K: Serialize,
    T: Serialize
[src]

Insert a value into the cache.

pub fn test<K>(&self, key: K) -> Result<State<()>, Error> where
    K: Serialize
[src]

Test an entry from the cache.

pub fn get<K, T>(&self, key: K) -> Result<State<T>, Error> where
    K: Serialize,
    T: DeserializeOwned
[src]

Load an entry from the cache.

pub async fn wrap<'a, K, F, T, E>(
    &'a self,
    key: K,
    age: Duration,
    future: F
) -> Result<T, E> where
    K: Serialize,
    F: Future<Output = Result<T, E>>,
    T: Serialize + DeserializeOwned,
    E: From<Error>, 
[src]

Wrap the result of the given future to load and store from cache.

Trait Implementations

impl Clone for Cache[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Unpin for Cache

impl Sync for Cache

impl Send for Cache

impl !UnwindSafe for Cache

impl !RefUnwindSafe for Cache

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,