Skip to main content

write_through_async

Function write_through_async 

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

Write-through(异步版):同时写入缓存和异步后端存储

写入顺序:先写后端存储,再写缓存。若后端存储写入失败,不写缓存。