import { LRUCache } from 'lru-cache'; /** * A cache that can be used to store data for the lifetime of the this object. * * It uses LRU caching, so it will automatically remove the least recently used items when it reaches its limits. * And also has expiries, so it will automatically replace items that have not been used for a while. * * It's a small wrapper over LRUCache npm package. * * @see https://www.npmjs.com/package/lru-cache */ export declare class Cache { readonly lruCache: LRUCache; /** * Wrap an async function with a cache. * * If the cache is empty, the async function will be run and the result will be stored in the cache. * If the cache is not empty, the async function will not be run and the result will be returned from the cache. * * All the cached items are stored by reference, so if you modify the returned cached data, it will also modify the cached data internally. * Nesting this function will also forward those references up the chain, so doing a cache wrap inside a cache wrap is a great way to share data between functions * and avoid unnecessary object creation and garbage collection. * * @param key The key to used to identify the cached data. * @param operation The async function to run if the cache is empty. * @param ttl The time to live of the cached data in milliseconds. * @returns The result of the async function. */ wrap(key: TKeys, operation: () => Promise, ttl?: number): Promise; /** * Invalidate a cache item, so that it will be fetched again the next time it is requested. * * @param key The key to used to identify the cached data. * @returns Whether the cache item was invalidated. */ dispose(key: TKeys): boolean; /** * Invalidate all cache items. * This will cause all cache items to be fetched again the next time they are requested. */ disposeAll(): void; }