Expand description
Redis-backed shared cache for Autumn applications.
This crate provides RedisCache, an implementation of the
autumn_web::cache::Cache trait backed by Redis, plus
RedisCachePlugin which wires it into the app via the plugin system.
§Usage
# autumn.toml
[cache]
backend = "redis"
[cache.redis]
url = "redis://redis:6379"
key_prefix = "myapp:cache"use autumn_cache_redis::RedisCachePlugin;
autumn_web::app()
.plugin(RedisCachePlugin::new())
.routes(routes![...])
.run()
.await;Values are serialized as JSON so they survive across replicas and restarts. Invalidation on replica A is immediately visible on replica B — no TTL lag.
Use autumn_web::cache::insert_cached / autumn_web::cache::get_cached
(which the #[cached] macro generates) to read and write values that are
serde::Serialize + serde::Deserialize. The plain autumn_web::cache::insert
/ autumn_web::cache::get functions work only for in-process backends.
CacheResponseLayer uses Autumn’s serde-aware cache path internally, so
HTTP response caching is supported with this Redis backend.
Structs§
- Invalidation
Retry - Retry policy for invalidation (
DELand the namespace sweep). - Redis
Cache - A
Cacheimplementation backed by Redis. - Redis
Cache Plugin - Autumn plugin that wires
RedisCacheas the global application cache.
Enums§
- Redis
Cache Error - Errors that can occur when constructing or using a
RedisCache.