import { MastraServerCache } from '@mastra/core/cache'; export interface RedisClient { get(key: string): Promise; set(key: string, value: unknown, ...args: unknown[]): Promise; llen(key: string): Promise; rpush(key: string, ...values: unknown[]): Promise; lrange(key: string, start: number, stop: number): Promise; del(...keys: string[]): Promise; expire(key: string, seconds: number): Promise; scan(cursor: string | number, ...args: unknown[]): Promise<[string | number, string[]]>; incr(key: string): Promise; /** * Server-side Lua scripting. Optional: clients without it fall back to the * two-round-trip `increment` + `listPush` path for `listPushIndexed`. */ eval?(...args: unknown[]): Promise; } export interface RedisServerCacheOptions { keyPrefix?: string; ttlSeconds?: number; /** * Run a Lua script with the given KEYS and ARGV. Defaults to the ioredis * calling convention (`eval(script, numKeys, ...keys, ...args)`); use * `nodeRedisPreset` / `upstashPreset` for those clients. */ evalScript?: (client: RedisClient, script: string, keys: string[], args: string[]) => Promise; setWithExpiry?: (client: RedisClient, key: string, value: unknown, seconds: number) => Promise; scanKeys?: (client: RedisClient, cursor: string | number, pattern: string, count: number) => Promise<[string | number, string[]]>; getListLength?: (client: RedisClient, key: string) => Promise; pushToList?: (client: RedisClient, key: string, value: unknown) => Promise; getListRange?: (client: RedisClient, key: string, start: number, stop: number) => Promise; } /** * Atomic "allocate index + append + refresh TTLs" used by `listPushIndexed`. * * KEYS[1] = list key, KEYS[2] = counter key * ARGV[1] = JSON-serialized object WITHOUT an `index` property * ARGV[2] = TTL in seconds (0 = no expiry) * * The index is spliced into the JSON text as the first property rather than * decoded/re-encoded with cjson, which would silently alter large integers * and sparse arrays. `JSON.stringify` of an object always starts with `{`, * so `{...}` → `{"index":N,...}` and `{}` → `{"index":N}`. */ export declare const LIST_PUSH_INDEXED_SCRIPT: string; export declare class RedisServerCache extends MastraServerCache { private client; private keyPrefix; private ttlSeconds; private setWithExpiry; private scanKeys; private getListLength; private pushToList; private getListRange; private evalScript; /** Set once scripting is known to be unusable (no `eval`, or Cluster CROSSSLOT). */ private scriptingDisabled; constructor(config: { client: RedisClient; }, options?: RedisServerCacheOptions); private getKey; private serialize; private deserialize; get(key: string): Promise; set(key: string, value: unknown, ttlMs?: number): Promise; listLength(key: string): Promise; listPush(key: string, value: unknown): Promise; listFromTo(key: string, from: number, to?: number): Promise; delete(key: string): Promise; clear(): Promise; increment(key: string): Promise; /** * Single round-trip index allocation + list append + TTL refresh via Lua. * This is the durable stream per-chunk hot path (issue #22477): the composed * default costs four awaited commands (INCR, EXPIRE, RPUSH, EXPIRE). */ listPushIndexed(listKey: string, counterKey: string, value: Record): Promise; } export declare const upstashPreset: Pick; export declare const nodeRedisPreset: Pick; //# sourceMappingURL=cache.d.ts.map