autumn-cache-redis
Redis-backed shared cache plugin for autumn-web applications.
This crate provides a RedisCache implementation that stores cached values in Redis, suitable
for multi-process or multi-instance Autumn deployments that need a shared, externally-accessible
cache instead of the default in-process Moka store.
Installation
One command adds the dependency at a version compatible with your app's
autumn-web, mounts the plugin in your autumn_web::app() builder chain, and
prints any configuration still needed. It is safe to re-run, and it refuses —
before touching any file — to install into an app on an incompatible
autumn-web version. See docs/plugins.md.
Manual install
If you would rather wire it yourself (or autumn plugin add could not find your
builder chain and printed these lines for you):
[]
= { = "0.10", = ["redis"] }
= "0.10"
Quick Start
autumn plugin add autumn-cache-redis writes this mount for you. It reads
[cache] at startup and installs the Redis cache only when
backend = "redis", so it is inert until you configure it:
use RedisCachePlugin;
async
To build the store yourself instead — bypassing the [cache] backend switch —
construct it and install it on the builder:
use RedisCache;
async
Configuration
Select the Redis backend and point it at your server in autumn.toml:
[]
= "redis"
[]
= "redis://127.0.0.1:6379"
RedisCachePlugin reads [cache] at startup: until backend = "redis" is set
it is a no-op and the default in-process Moka cache stays in use.
The URL follows the standard Redis URL format and is passed directly to the redis crate's
connection manager.
Invalidation errors
Invalidation retries a failed DEL with bounded, jittered backoff. The
default is 3 attempts (two sleeps, about 90 ms at most). Change it with
RedisCache::with_invalidation_retry:
use ;
use Duration;
let cache = from_config
.await?
.with_invalidation_retry;
invalidate_asyncandinvalidate_namespace_asyncreturn the final error. They are real async calls and work on any Tokio runtime.- The sync
invalidateandclearcannot return an error. They log it withwarn!and count it inautumn_cache_invalidation_failures_total. - All sync methods,
invalidateandclearincluded, useblock_in_place. They need a multi-thread Tokio runtime.
Status
This crate is the first-party Redis cache plugin for autumn-web. It targets the same
autumn-web version it is published alongside.