/*! * Copyright (c) 2020-2026 Digital Bazaar. All rights reserved. */ import { LRUCache } from 'lru-cache'; export interface CacheOptions extends LRUCache.OptionsBase, unknown> { disposeOnSettle?: boolean; maxAge?: number; } /** * LruCache uses the npm module `lru-cache` to memoize promises. * * @see https://www.npmjs.com/package/lru-cache * @see https://en.wikipedia.org/wiki/Memoization * @param {object} cacheOptions - Options for `lru-cache`. * See the npm docs for more options. * @param {number} [cacheOptions.max=1000] - The max number of items in the * cache. If no `max` is specified and no `maxSize` is specified, then `max` * will default to `1000`, ensuring the cache is bounded. * @param {number} [cacheOptions.maxSize] - DEPRECATED. Use `ttl`. * @param {number} [cacheOptions.ttl] - The time-to-live of an item in ms. * @param {Function} [cacheOptions.sizeCalculation] - A function that will * calculate the size of an item; see lru-cache documentation. * @param {boolean} [cacheOptions.updateAgeOnGet=false] - When using * time-expiring entries with `ttl`, setting this to true will make * each entry's effective time update to the current time whenever it is * retrieved from cache, thereby extending the expiration date of the entry. * @param {boolean} [cacheOptions.disposeOnSettle=false] - When set to true * entries will be removed from cache once they've settled. This is to only * be used when one needs a promise queue. * * @returns {LruCache} The class. */ export declare class LruCache { options: CacheOptions; cache: LRUCache>; constructor(cacheOptions?: CacheOptions); /** * Deletes a key from the LRU cache. * * @param {string} key - A key for the cache. * * @returns {boolean} */ delete(key: string): boolean; /** * Memoizes a promise via an LRU cache. * * @param {object} options - Options to use. * @param {string} options.key - A key for the cache. * @param {Function} options.fn - A Function that returns a promise to memoize. * @param {object} [options.options] - The LRU cache options to pass * if setting the value in the cache; note: only those options supported * by the underlying LRU cache instance will be supported. * * @returns {Promise} - The result of the memoized promise. */ memoize({ key, fn, options }: { key: string; fn: () => Promise; options?: Partial; }): Promise; } //# sourceMappingURL=LruCache.d.ts.map