Skip to main content

read_through_async

Function read_through_async 

Source
pub async fn read_through_async<F, Fut>(
    cache: &dyn Cache,
    key: &str,
    ttl: Option<Duration>,
    loader: F,
) -> Result<Option<Vec<u8>>, CacheError>
where F: FnOnce() -> Fut, Fut: Future<Output = Result<Option<Vec<u8>>, CacheError>>,
Expand description

Read-through(异步版):缓存未命中时通过异步 loader 回源加载,写入缓存后返回

用于数据库等异步数据源的回源加载场景。