Skip to main content

fetch_cached

Function fetch_cached 

Source
pub async fn fetch_cached<K: KvStore>(
    kv: &K,
    client: &Client,
    iri: &str,
    ttl: Duration,
    on_store_error: impl FnMut(KvError),
) -> Result<String, Error>
Expand description

fetch, kept in kv for ttl (Mastodon keeps it for CACHE_TTL) under ["jsonld", "context", iri], as Rails.cache keeps it under jsonld:context:<iri>. Only a context that was taken is kept.

The store is a cache, and a failing one is treated as Rails.cache treats a Redis it cannot reach: a read that fails is a miss, and a write that fails still returns what was fetched. on_store_error is told of each failure, for the application to log.

ยงErrors

As fetch.