import type { CommonLogger } from '../log/commonLogger.js'; import type { AnyAsyncFunction, AnyFunction, AnyObject, MaybeParameters } from '../types.js'; import type { MethodDecorator } from './decorator.util.js'; import type { AsyncMemoCache } from './memo.util.js'; export interface AsyncMemoOptions { /** * Provide a custom implementation of AsyncMemoCache. * Function that creates an instance of `AsyncMemoCache`. */ cacheFactory: () => AsyncMemoCache; /** * Provide a custom implementation of CacheKey function. */ cacheKeyFn?: (args: MaybeParameters) => any; /** * Default to `console` */ logger?: CommonLogger; } export interface AsyncMemoInstance { /** * Clears the cache. */ clear: () => Promise; getInstanceCache: () => Map; getCache: (instance: AnyAsyncFunction) => AsyncMemoCache | undefined; } /** * Like `@_Memo`, but allowing async MemoCache implementation. * * Implementation is more complex than `@_Memo`, because it needs to handle "in-flight" Promises * while waiting for cache to resolve, to prevent "async swarm" issue. * * @experimental consider normal `@_Memo` for most of the cases, it's stable and predictable */ export declare const _AsyncMemo: (opt: AsyncMemoOptions) => MethodDecorator; /** Call it on a method that is decorated with `@_AsyncMemo` to get access to additional functions, e.g `clear` to clear the cache, or get its underlying data. */ export declare function _getAsyncMemo(method: AnyFunction): AsyncMemoInstance;