/** * # Cache System * * ## Description * A cache of values with a max size to ensure that too much old data is not stored. * * ## Usage * * ```ts * import { Cache } from 's2-tools'; * * const onDelete = (key: string, value: string) => { * console.log(`Deleted key ${key} with value ${value}`); * }; * const cache = new Cache(10, onDelete); * cache.set('key', 'value'); * console.log(cache.get('key')); // 'value' * cache.delete('key'); * ``` */ export declare class Cache extends Map { private readonly maxSize; private onDelete?; order: K[]; /** * @param maxSize - the max size of the cache before dumping old data * @param onDelete - if provided, will be called when a value is removed */ constructor(maxSize: number, onDelete?: ((key: K, value: V) => void) | undefined); /** * @param key - the offset position in the data * @param value - the value to store * @returns this */ set(key: K, value: V): this; /** * @param key - the offset position in the data * @returns - the value if found */ get(key: K): V | undefined; /** * @param key - the offset position in the data * @returns - true if found */ delete(key: K): boolean; } //# sourceMappingURL=cache.d.ts.map