/** * Small deterministic LRU cache for rendered blocks, with de-duplication of * renders that are already in flight. * @module markdown/cache */ export type Cache = { /** * Returns the value and marks it most recently used. */ get: (key: string) => T | undefined; set: (key: string, value: T, bytes?: number) => void; has: (key: string) => boolean; delete: (key: string) => boolean; clear: () => void; /** * Return the cached value, share an in-flight render, or run `produce` and store its result. */ memo: (key: string, produce: () => Promise, bytesOf?: (value: T) => number) => Promise; /** * Number of entries. */ size: number; /** * Approximate bytes held. */ bytes: number; }; /** * @template T * @typedef {object} Cache * @property {(key: string) => T | undefined} get Returns the value and marks it most recently used. * @property {(key: string, value: T, bytes?: number) => void} set * @property {(key: string) => boolean} has * @property {(key: string) => boolean} delete * @property {() => void} clear * @property {(key: string, produce: () => Promise, bytesOf?: (value: T) => number) => Promise} memo * Return the cached value, share an in-flight render, or run `produce` and store its result. * @property {number} size Number of entries. * @property {number} bytes Approximate bytes held. */ /** * Create an LRU cache. Eviction order depends only on the sequence of calls. * @template T * @param {{ max?: number, maxBytes?: number }} [options] `max` entries (default 200) and * `maxBytes` of stored payload (default 64 MiB). * @returns {Cache} * @public */ export declare function createCache(options?: { max?: number; maxBytes?: number; }): Cache;