@mastra/core
Version:
37 lines • 1.44 kB
TypeScript
import { MastraServerCache } from './base.js';
/**
* Options for InMemoryServerCache
*/
export interface InMemoryServerCacheOptions {
/**
* Maximum number of items to store in cache.
* Defaults to 1000.
*/
maxSize?: number;
/**
* Default TTL in milliseconds for cached items.
* Defaults to 300000 (5 minutes).
* Set to 0 to disable TTL (items persist until explicitly deleted or evicted).
*/
ttlMs?: number;
}
export declare class InMemoryServerCache extends MastraServerCache {
private cache;
private ttlMs;
constructor(options?: InMemoryServerCacheOptions);
get(key: string): Promise<unknown>;
set(key: string, value: unknown, ttlMs?: number): Promise<void>;
listLength(key: string): Promise<number>;
listPush(key: string, value: unknown): Promise<void>;
listFromTo(key: string, from: number, to?: number): Promise<unknown[]>;
delete(key: string): Promise<void>;
clear(): Promise<void>;
increment(key: string): Promise<number>;
/**
* Allocation and append happen in one synchronous critical section. JS runs
* one task at a time and nothing here awaits, so no other publish can observe
* the counter after it is bumped but before the entry is appended.
*/
listPushIndexed(listKey: string, counterKey: string, value: Record<string, unknown>, ttlMs?: number): Promise<number>;
}
//# sourceMappingURL=inmemory.d.ts.map