import type { JSON } from "type-party"; import type { AnyParams, AnyValidators, CacheSpec, EntryForId, Logger, NormalizedParams, Store, StoreEntryInput, StoreGetManyRequest, StoreGetManyResult } from "../types/index.js"; type SupportedCacheSpec = CacheSpec; /** * A {@link Store} that persists entries as JSON files in a single directory -- * one file per `(id, variantKey)` tuple. Designed for use cases where the * cache lives on disk and is portable across process invocations (e.g., * downloaded/uploaded as a CI artifact between runs). * * Files are named by a stable MurmurHash64 hash of `[id, variantKey]`, so * filenames are always filesystem-safe and stable for the same logical key. * Writes go through a unique `.tmp` file + rename so a crashed process never * leaves a half-written entry behind. * * The store keeps an in-memory index of every non-expired file's lookup * metadata, populated lazily on the first `get`/`store`/`delete`/`getMany` * call. Initial scans are O(files-on-disk); subsequent metadata lookups are * O(variants-for-that-id), and matching entries are read from disk only after * the index says they apply to the request. * Because the index is not refreshed after initialization, each FileStore * instance must own its directory: it needs to be the only writer for that * directory while the instance is alive. Files written by other code or by * another FileStore instance after initialization will not appear in this * store's index. * * Operations are serialized per FileStore instance. This keeps index updates, * file writes, and cleanup deletes ordered without requiring fragile * generation checks. */ export declare class FileStore implements Store { #private; /** * @param opts.directory Persisted cache directory. Created on first write. * The FileStore owns this directory and must be its only writer while the * instance is alive; external writes after initialization are missed by * the in-memory index. * @param opts.fallbackDeleteAfter Seconds to keep entries the cache asked * to keep "forever" (`Infinity`). Defaults to 30 days. * @param opts.logger Custom logger; defaults to silently dropping messages. */ constructor(opts: { directory: string; fallbackDeleteAfter?: number; logger?: Logger; }); get(id: Id, normalizedParams: NormalizedParams, options?: { signal?: AbortSignal; }): Promise[]>; getMany[]>(requests: Reqs, options?: { signal?: AbortSignal; }): Promise>; store(entries: readonly StoreEntryInput[]): Promise; delete(id: Spec["id"]): Promise; close(): Promise; [Symbol.asyncDispose](): Promise; } export {}; //# sourceMappingURL=FileStore.d.ts.map