/** * A cache that expires entries after a given time-to-live (TTL). It uses a * `Map` in memory to store the entries. */ export declare class TtlCache { #private; readonly ttl: number; data: Map; expiration: Map; /** * @param ttl The default TTL for entries in milliseconds. Defaults to * `Number.POSITIVE_INFINITY`. */ constructor(ttl?: number); /** * Sets a value in the cache. * @param key The key to set. * @param value The value to set. * @param ttl The TTL for the entry in milliseconds. Defaults to the default * TTL. * @throws If the value is `undefined`. */ set(key: Key, value: Value, ttl?: number): void; /** * Gets a value from the cache. * @param key The key to get. * @returns The value or `undefined` if the entry has expired or does not * exist. */ get(key: Key): Value | undefined; /** * Checks if a key exists in the cache. * @param key The key to check. * @returns `true` if the key exists and has not expired, `false` otherwise. */ has(key: Key): boolean; /** * Deletes a key and its value from the cache. If the key does not exist, this * method does nothing. * @param key The key to delete. * @returns `true` if the key existed and was deleted, `false` otherwise. */ delete(key: Key): boolean; /** * Clears the cache. All entries will be deleted. */ clear(): void; }