/** * RedisStore — Redis-backed `MemoryStore` adapter (peer-dep `ioredis`). * * Import from the canonical subpath (the `agentfootprint/memory-redis` alias * was removed in 4.0.0): * * import { RedisStore } from 'agentfootprint/memory-providers'; * * const store = new RedisStore({ url: 'redis://localhost:6379' }); * * Pattern: Adapter (GoF) — translates the `MemoryStore` interface onto * Redis primitives (key/value for entries, set for signatures, * hash for feedback aggregates). * Role: Outer ring. Lazy-requires `ioredis`; no runtime cost when * another adapter is in use. * Emits: N/A (storage adapters don't emit; recorders observe the * memory pipeline that calls them). * * Vector search (`search()`) is NOT implemented in this adapter — RedisSearch * is a separate Redis module with its own API surface. A `RedisSearchStore` * may ship in a future release. RAG users with v2.3 should use * `InMemoryStore` until the search-capable adapter lands. * * Concurrency model: * - `put` / `putMany` use simple SET / pipelined SET (last-write-wins). * - `putIfVersion` uses a small Lua script for atomic version compare-and-swap. * - Multi-writer correctness ⇒ prefer `putIfVersion` in stage code. */ import type { ListOptions, ListResult, MemoryStore, PutIfVersionResult } from '../../memory/store/types.js'; import type { MemoryEntry } from '../../memory/entry/index.js'; import type { MemoryIdentity } from '../../memory/identity/index.js'; /** * Minimal `ioredis` client surface this adapter needs. Defined locally so * we don't take a hard import on `ioredis` (lazy peer-dep) and tests can * inject a mock implementation via `_client`. */ export interface RedisLikeClient { get(key: string): Promise; set(key: string, value: string, ...args: ReadonlyArray): Promise; del(...keys: ReadonlyArray): Promise; sadd(key: string, ...members: ReadonlyArray): Promise; srem(key: string, ...members: ReadonlyArray): Promise; sismember(key: string, member: string): Promise; smembers(key: string): Promise; hgetall(key: string): Promise>; hset(key: string, ...args: ReadonlyArray): Promise; scan(cursor: string, match: 'MATCH', pattern: string, count: 'COUNT', n: number): Promise; eval(script: string, numKeys: number, ...args: ReadonlyArray): Promise; pipeline(): RedisLikePipeline; quit(): Promise; } export interface RedisLikePipeline { set(key: string, value: string, ...args: ReadonlyArray): RedisLikePipeline; sadd(key: string, ...members: ReadonlyArray): RedisLikePipeline; exec(): Promise; } export interface RedisStoreOptions { /** * Connection URL (e.g. `redis://default:password@host:6379/0`). Required * unless `_client` is supplied. */ readonly url?: string; /** * Pre-built `ioredis` client. Use this when the host app already manages * a Redis connection pool. Adapter does NOT call `quit()` on a borrowed * client — caller owns the lifecycle. */ readonly client?: RedisLikeClient; /** Key prefix for namespace isolation across apps sharing one Redis. Default `'agentfootprint'`. */ readonly prefix?: string; /** * SCAN page size when iterating keys. Default 100. Larger = fewer * round-trips but more memory per response. Adapter never uses `KEYS *` * (which blocks Redis). */ readonly scanCount?: number; /** * @internal Test injection point. When provided, skips the SDK require. */ readonly _client?: RedisLikeClient; } /** * Redis-backed `MemoryStore`. Implements every method except `search()`. * * @throws when `ioredis` is not installed and no `_client` is supplied. */ export declare class RedisStore implements MemoryStore { private readonly client; private readonly prefix; private readonly scanCount; private readonly ownsClient; private closed; constructor(options?: RedisStoreOptions); private nsKey; private entryKey; private indexKey; private sigKey; private feedbackKey; get(identity: MemoryIdentity, id: string): Promise | null>; put(identity: MemoryIdentity, entry: MemoryEntry): Promise; putMany(identity: MemoryIdentity, entries: readonly MemoryEntry[]): Promise; /** * Optimistic concurrency via a small Lua script — atomic * compare-and-swap on the JSON-encoded `version` field. */ putIfVersion(identity: MemoryIdentity, entry: MemoryEntry, expectedVersion: number): Promise; list(identity: MemoryIdentity, options?: ListOptions): Promise>; delete(identity: MemoryIdentity, id: string): Promise; seen(identity: MemoryIdentity, signature: string): Promise; recordSignature(identity: MemoryIdentity, signature: string): Promise; feedback(identity: MemoryIdentity, id: string, usefulness: number): Promise; getFeedback(identity: MemoryIdentity, id: string): Promise<{ average: number; count: number; } | null>; /** * GDPR — drop every key under this identity's namespace. */ forget(identity: MemoryIdentity): Promise; /** * Close the underlying Redis connection — only when this adapter * owns it. Borrowed clients (passed via `client` option) are left to * the caller. Idempotent. */ close(): Promise; private ensureOpen; } //# sourceMappingURL=redis.d.ts.map