DocsRendering and delivery
Caching & revalidation
Cache typed derived data through a replaceable store, or opt safe public pages into complete-document caching.
Typed application-data cache
use std::time::Duration;
use crate::rahti::cache;
cache::put("products:42", &summary, Duration::from_secs(300)).await?;
let summary = cache::get::<ProductSummary>("products:42").await?;
cache::remove("products:42").await?;Values use JSON serialization. A miss or expired key returns Ok(None); serialization and backend failures remain errors. Stable namespaced keys must include every user, tenant, locale, permission, and input dimension that changes the result.
| Operation | Purpose |
|---|---|
| get / put | Read or write a typed value with finite expiration. |
| put_forever | No time expiry, though a bounded store may still evict it. |
| remove / clear | Remove one key or the application's complete backend namespace. |
| store | Access the installed raw byte-store contract. |
Page caching
use crate::rahti::cache::PageCache;
pub fn cache() -> PageCache {
PageCache::seconds(60).tags(["catalog", "featured-products"])
}
pub async fn page() -> Html {
// Render public, deterministic content.
}A page policy caches the complete rendered document for anonymous safe GETs. The key includes host, path, and query. X-Rahti-Cache reports MISS, HIT, or BYPASS.
Revalidate after authoritative writes
save_product(input).await?;
cache::revalidate_path("/products").await?;
cache::revalidate_tag("catalog").await?;Path revalidation invalidates every query variant of one concrete path. Tag revalidation invalidates pages declaring the same stable application tag. It advances generation tokens rather than scanning the backend, so a shared adapter must retain those tokens at least as long as older page entries can survive.
