Jido.Memory.Store.Redis (Jido Memory v1.0.0)

View Source

Redis-backed memory store.

This adapter persists canonical Jido.Memory.Record structs in Redis without introducing a hard Redis client dependency into jido_memory.

Callers provide a :command_fn option, typically a thin wrapper around a client such as Redix:

fn args -> Redix.command(:memory_redis, args) end

Options

  • :command_fn (required) - fn([term()]) -> {:ok, term()} | {:error, term()}

  • :prefix (optional, default "jido:memory") - key namespace prefix
  • :ttl (optional) - Redis key TTL in milliseconds for stored record values

Key Layout

{prefix}:record:{namespace}:{id}        -> serialized `Record`
{prefix}:meta:{namespace}:{id}          -> serialized index metadata
{prefix}:z:ns:{namespace}:time          -> ZSET of ids by observed_at
{prefix}:z:ns:{namespace}:class:{class} -> ZSET of ids by observed_at
{prefix}:s:ns:{namespace}:tag:{tag}     -> SET of ids
{prefix}:z:expires                      -> ZSET of namespace/id pairs by cleanup time

The metadata key is intentionally left without a Redis TTL so expired record keys can still be deindexed when they are observed later by reads or pruning.

Summary

Types

index_metadata()

@type index_metadata() :: %{
  observed_at: integer(),
  class: term(),
  tags: [String.t()],
  cleanup_at: integer() | nil
}