Expand description
Redis L2 shared-cache storage driver for Agent Assembly.
This crate implements three of the high-frequency aa_storage traits
against a Redis (or Valkey) instance so multiple Assembly processes can
coordinate through one shared cache instead of each hitting the L3 store:
RedisSessionStore—SessionStoreRedisRateLimitCounter—RateLimitCounterRedisPolicyStore—PolicyStore, used as a read-through cache in front of the authoritative store
Build a RedisBackend from a RedisStorageConfig and hand out the
individual stores, or construct each store directly over a shared Pool.
§Key layout
Every key is namespaced under aa::
| Store | Key | Value |
|---|---|---|
| session | aa:session:<session_id> | hash (agent_id, started_at_ns) |
| rate limit | aa:ratelimit:<key> | integer counter |
| policy | aa:policy:<agent_id> | JSON PolicyDocument |
<session_id> and <agent_id> are the lower-case hex encodings of the
16-byte ids.
§TTL and invalidation semantics
- Sessions expire after
SESSION_TTL_SECSseconds. The TTL is re-armed on everysaveso an actively written session never lapses;deletedrops it immediately and is idempotent. - Rate-limit counters carry the window length supplied to
incrementas their TTL. The expiry is armed exactly once — on the first increment that creates the key — so the window is fixed: it starts at the first hit and is not pushed forward by later increments within the same window.resetdeletes the key. - Policies are cached with an explicit per-entry TTL via
RedisPolicyStore::cache_policy(DEFAULT_POLICY_CACHE_TTL_SECSis the suggested default).invalidatedeletes the cached key so the next read misses and reloads from the authoritative store; it is idempotent.
Modules§
- factory
- Factories that build the Redis-backed stores for the
aa-storagedriver registry.
Structs§
- Redis
Backend - A connected Redis storage driver.
- Redis
Policy Store - Redis-backed read-through
PolicyStore. - Redis
Rate Limit Counter - Redis-backed
RateLimitCounter. - Redis
Session Store - Redis-backed
SessionStore. - Redis
Storage Config - Settings for the
[storage.redis]subsection ofagent-assembly.toml.
Constants§
- DEFAULT_
POLICY_ CACHE_ TTL_ SECS - Suggested default TTL, in seconds, for a cached policy entry.
- DRIVER_
NAME - The name this driver registers under in storage configuration, i.e. the
[storage.<name>]subsection and the registry key (storage.backend = "redis"). - SESSION_
TTL_ SECS - Time-to-live applied to a session record on every
save, via RedisEXPIRE.
Functions§
- build_
pool - Build a
deadpool_redis::Poolsized topool_size. - register
- Register the Redis factories for the kinds redis backs — policy, session, and
rate-limit — into
regunderDRIVER_NAME("redis").
Type Aliases§
- Pool
- Pooled Redis connection handle, re-exported for callers that build stores
directly with
RedisSessionStore::newand friends. Type alias for usingdeadpool::managed::Poolwithredis.