import { Cache } from './cache'; import type { CacheEntry } from './cache'; /** * Generic async cache interface. * @internal */ export interface AsyncCacheInterface { /** * This is called when an entry is added to the cache. * @param key - The cache key to store the item under. * @param item - The destination alongside an expiration time to store in the cache. */ set(key: string | undefined, item: CacheEntry): Promise; /** * This is called when an entry shall be retrieved from the cache. * @param key - The cache key the item is stored under. */ get(key: string | undefined): Promise; /** * This is called when checking if a given key occurs in the cache. * @param key - The cache key the item should be stored under, if available. */ hasKey(key: string): Promise; /** * This can be called to remove all existing entries from the cache. */ clear(): Promise; } /** * @internal * Async wrapper around Cache. */ export declare class AsyncCache implements AsyncCacheInterface { cache: Cache; constructor(defaultValidityTime?: number); /** * Specifies whether an entry with a given key is defined in cache. * @param key - The entry's key. * @returns A boolean value that indicates whether the entry exists in cache. */ hasKey(key: string): Promise; /** * Getter of cached entries. * @param key - The key of the entry to retrieve. * @returns The corresponding entry to the provided key if it is still valid, returns `undefined` otherwise. */ get(key: string | undefined): Promise; /** * Setter of entries in cache. * @param key - The entry's key. * @param item - The entry to cache. * @returns A promise to oid. */ set(key: string | undefined, item: CacheEntry): Promise; /** * Clear all cached items. * @returns A promise to void. */ clear(): Promise; }