import { CacheProvider } from '@strapi-community/plugin-rest-cache/types'; import type { CacheKey, Milliseconds } from '@strapi-community/plugin-rest-cache/types'; /** * The quick-lru constructor, as it arrives from a dynamic import. * * Deliberately loose in its options: everything the user put under * `provider.options` is forwarded to quick-lru untouched, and quick-lru * validates it itself (it throws unless `maxSize` is a number greater than 0). */ type QuickLRUConstructor = new (options: Record) => unknown; /** * Everything accepted under `provider.options` in the plugin configuration. * * `ttl` is consumed here as cache-manager's store-level default lifetime; every * other key is handed to quick-lru as-is. */ export interface MemoryCacheProviderOptions { /** Store-level default lifetime, in milliseconds. */ ttl?: Milliseconds | number; /** Maximum number of entries held before the least recently used are evicted. */ maxSize?: number; /** Legacy alias for `maxSize`, renamed before the store is constructed. */ max?: number; [option: string]: unknown; } export declare class MemoryCacheProvider extends CacheProvider { private readonly cache; /** * quick-lru v7 is ESM-only, so it cannot be require()d from CommonJS on Node * versions without require(esm) (added in 20.19). Loading it with a dynamic * import works on every supported Node version, which is why construction * goes through this factory rather than the constructor. * * Do not "simplify" this back to a top-level require - see * https://github.com/strapi-community/plugin-rest-cache/issues/128 * * The tsconfig compiles to `module: Node16` for the same reason: under plain * `module: CommonJS` TypeScript rewrites this `import()` into a `require()` * and reintroduces the bug at build time. */ static create(options: MemoryCacheProviderOptions): Promise; /** * Prefer MemoryCacheProvider.create(), which resolves QuickLRU for you. * * @param options * @param QuickLRU the quick-lru constructor */ constructor(options: MemoryCacheProviderOptions, QuickLRU: QuickLRUConstructor); get(key: CacheKey | string): Promise; /** * @param maxAge in milliseconds */ set(key: CacheKey | string, val: unknown, maxAge?: Milliseconds | number): Promise; del(key: CacheKey | string | string[]): Promise; delMany(keys: Array): Promise; keys(): Promise; clear(): Promise; get ready(): boolean; } export {};