tinycache
Features
tinycache is minimal file cache with binary serialization:
- Fallback with
get_cached_or_fetch - Binary serialization
- Optional max age for stored values
- optional tracing feature
- Invalidates if fails to read (for fast iteration)
- Uri safe with
sha1 - 4 deps (serde, bincode, tracing, sha1)
Features Overview
Get cached or fetch pattern (read, invalidate if old or non compatible, fetch and write if does not exist):
let cache_ref = new.max_age;
let expensive_value = cache_ref.get_cached_or_fetch;
Read, write (ya):
let cache_ref = new;
// write does not return result, it logs tracing if there is an issue
// found that to be more useful
cache_ref.write;
if let Some = cache_ref.
Under the hood using bincode for small file fast read/write:
let bytes = serialize.map_err?;
Item keys formatted using sha1:
Tracing dep and logging can be disabled with a feature:
[]
= ["tracing"]
= ["dep:tracing"]