export interface AsyncLruCacheOptions { maxCount: number; maxLife: number; maxSize: number; sizeFunc: (item: T) => number; } declare type AsyncLruCacheOptionsParameter = Partial>; declare type LoaderFunc = (key: string, ...context: any[]) => Promise; /** * AsyncLruCache is an asynchronous key-value container class * which has the following features. * * 1. Keys are strings. * 2. Values are always returned via promises. * 3. Automatically removes contents using three types of limits * (number of items, total size, life) * * To use this class you have to pass a loader function to the constructor. * The loader function must take a key as an argument and return a Promise * that will resolve with the corresponding loaded item. */ export default class AsyncLruCache { private timer; private lru; private pendings; private loader; private options; private totalSize; private static collection; private defaultOptions; constructor(loader: LoaderFunc, options?: AsyncLruCacheOptionsParameter); /** * Stops the internal timer. */ dispose(): void; /** * Does not load anything, but synchronously returns the specified item * only if it is already loaded. */ touch(key: string): T | undefined; /** * Asynchronously returns the specified item using a Promise. * When a new key is passed, the loader function will be triggered. * @param key The string key of the item wanted. * @param context Optional parameters passed to the loader function. * @return The resulting item, wrapped with a Promise. */ get(key: string, ...context: any[]): Promise; getAt(index: number): T; indexOf(key: string): number; remove(key: string): void; readonly length: number; getTotalSize(): number; protected shift(): T | undefined; protected truncate(): void; /** * Checks the max age. This will called automatically, * but it's possible to call this manually. */ checkTtl(): void; /** * Get total of all instance cache size. */ static getTotalOfTotalSize(): number; } declare type Decorate = (loader: L) => L; export declare function asyncLruCachify(options: AsyncLruCacheOptionsParameter): Decorate>; export {};