import type { SevLogger } from '@transloadit/sev-logger'; import type { Schema } from 'zod'; export interface McacheOpts { ttlMs?: number; zodSchema?: Schema; logger?: SevLogger; /** * Maximum number of entries in the cache. When exceeded, oldest entries are removed. * Defaults to 10,000 entries. */ maxSize?: number; /** * Custom key generator function. If not provided, uses JSON.stringify. */ keyFn?: (...args: unknown[]) => string; } /** * Memory cache abstraction to help cache function results in-process. * * Example: * * const cache = new Mcache({ ttlMs: 1000 * 60 * 10 }) * * async function fetchInstances(region: string): Promise { * return cache.get(region, async () => { * // Do work, e.g. fetch instances from AWS * return await this._fetchInstances(region) * }) * } */ export declare class Mcache { #private; constructor(opts?: McacheOpts); /** * Get a value from cache, or compute it using the provided function. * The cache key is generated from the args using JSON.stringify by default, * or using the custom keyFn if provided. */ get(producer: () => Promise | T, ...args: unknown[]): Promise; /** * Set a value in the cache directly. */ set(value: T, ...args: unknown[]): void; /** * Check if a key exists in cache and is not expired. */ has(...args: unknown[]): boolean; /** * Clear all entries from the cache. */ clear(): void; /** * Delete a specific entry from the cache. */ delete(...args: unknown[]): boolean; /** * Get the current size of the cache. */ get size(): number; /** * Clean up expired entries and enforce size limit. */ cleanup(): void; } //# sourceMappingURL=mcache.d.ts.map