Skip to main content

Crate autumn_cache_redis

Crate autumn_cache_redis 

Source
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§

InvalidationRetry
Retry policy for invalidation (DEL and the namespace sweep).
RedisCache
A Cache implementation backed by Redis.
RedisCachePlugin
Autumn plugin that wires RedisCache as the global application cache.

Enums§

RedisCacheError
Errors that can occur when constructing or using a RedisCache.