One cache API, six stores.
Get, put, remember and atomic locks over memory, Redis, Redis Cluster, Memcached, DynamoDB or Cloudflare Workers KV.
What you get
rememberandremember_foreverfor the pattern nearly every cache use is.- Typed reads and writes through
CacheExt:get_json::<Post>,put_json. - Atomic locks — the scheduler’s overlap protection uses them.
- A store failure the cache works around is a
CacheFailedevent, not a silent miss. - Honest limit: Workers KV is eventually consistent and has no atomic add.
In the docs
src/app/http/controllers/stats_controller.rs
use rainier_framework::cache::CacheExt;
use rainier_framework::facades::Cache;
pub async fn totals() -> Result<Response> {
let posts = resolve::<PostRepository>()?;
// Computed once, then read from the store for five minutes.
let totals = Cache::instance()
.remember("stats.totals", Some(Duration::from_secs(300)), || async {
posts.totals().await
})
.await?;
Ok(Response::json(&totals))
}
Up close
Select an image to see it full size.