import { Awaitable } from '../Types'; /** * A function that returns true if the value is expired. * @argument value the value to evaluate. */ export type IExpiryPolicyDelegate = (value?: T) => boolean; export interface IAsyncCacheItem { getValueAsync(): Promise; } export interface ICache { add(key: TKey, value: Awaitable, expiryPolicy: IExpiryPolicyDelegate): void; addOrGetAsync(key: TKey, factory: (key: TKey) => Awaitable, expiryPolicy: IExpiryPolicyDelegate): Promise; addOrReplace(key: TKey, value: Awaitable, expiryPolicy: IExpiryPolicyDelegate): void; cleanAsync(): Promise; getAsync(key: TKey): Promise; tryGetAsync(key: TKey): Promise<{ success: boolean; value?: Promise; }>; replace(key: TKey, value: Awaitable, expiryPolicy: IExpiryPolicyDelegate): void; }