Expand description
Cache backends and HTTP route caching for siderite applications.
MemoryCache is a process-local LRU with per-entry TTL.
RedisCache (feature redis) wraps siderite_backends::redis::RedisStore.
RouteCache is a tower layer for App::layer that caches GET/HEAD 200
responses.
use siderite_cache::{Cache, CacheExt, MemoryCache};
use std::time::Duration;
let cache = MemoryCache::new(128);
cache.set("greeting", b"hello".to_vec(), None).await.unwrap();
assert_eq!(
cache.get("greeting").await.unwrap().as_deref(),
Some(&b"hello"[..])
);
cache
.set_json("n", &7u32, Some(Duration::from_secs(60)))
.await
.unwrap();
assert_eq!(cache.get_json::<u32>("n").await.unwrap(), Some(7));Structs§
- Admit
Marker - What
Cache::admit_markermust decide. - Memory
Cache - In-memory LRU cache with per-entry time-to-live.
- Memory
Cache Limits - Hard byte-admission limits for process-local cache storage.
- Redis
Cache - Redis-backed
Cache. - Route
Cache - Middleware that caches successful GET and HEAD responses.
Enums§
- Admission
- Outcome of
Cache::admit_marker. - Cache
Error - Failure from a
Cacheoperation.
Constants§
- DEFAULT_
GENERATION_ TTL - Default lifetime of a target’s generation marker (one hour).
- DEFAULT_
MAX_ BODY_ BYTES - Largest body stored by default (1 MiB).
- DEFAULT_
MAX_ NEW_ TARGETS - Default admission budget: new markers per namespace per
generation_ttlwindow.