autocache 0.4.0

automatic cache management
Documentation
1
2
3
4
5
6
7
8
9
10
11
use anyhow::Result;
use futures::future::BoxFuture;

type SingleLoadFn<K, V, E> = dyn Fn(K, E) -> BoxFuture<'static, Result<Option<V>>> + Send + Sync;
type MultiLoadFn<K, V, E> =
    dyn Fn(Vec<(K, E)>) -> BoxFuture<'static, Result<Vec<(K, V)>>> + Send + Sync;

pub enum Loader<K, V, E> {
    SingleLoader(Box<SingleLoadFn<K, V, E>>),
    MultiLoader(Box<MultiLoadFn<K, V, E>>),
}