Skip to main content

Crate aa_storage_redis

Crate aa_storage_redis 

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

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::

StoreKeyValue
sessionaa:session:<session_id>hash (agent_id, started_at_ns)
rate limitaa:ratelimit:<key>integer counter
policyaa: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_SECS seconds. The TTL is re-armed on every save so an actively written session never lapses; delete drops it immediately and is idempotent.
  • Rate-limit counters carry the window length supplied to increment as 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. reset deletes the key.
  • Policies are cached with an explicit per-entry TTL via RedisPolicyStore::cache_policy (DEFAULT_POLICY_CACHE_TTL_SECS is the suggested default). invalidate deletes 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-storage driver registry.

Structs§

RedisBackend
A connected Redis storage driver.
RedisPolicyStore
Redis-backed read-through PolicyStore.
RedisRateLimitCounter
Redis-backed RateLimitCounter.
RedisSessionStore
Redis-backed SessionStore.
RedisStorageConfig
Settings for the [storage.redis] subsection of agent-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 Redis EXPIRE.

Functions§

build_pool
Build a deadpool_redis::Pool sized to pool_size.
register
Register the Redis factories for the kinds redis backs — policy, session, and rate-limit — into reg under DRIVER_NAME ("redis").

Type Aliases§

Pool
Pooled Redis connection handle, re-exported for callers that build stores directly with RedisSessionStore::new and friends. Type alias for using deadpool::managed::Pool with redis.