import { Queue } from "../Queue"; import { IQueueNode } from "./_types/IQueueNode"; import { TCacheKeysList } from "./_types/TCacheKeysList"; import { TCacheMap } from "./_types/TCacheMap"; declare type IMapVal = { value: V; node: IQueueNode; }; /** * A class to cache items that are created for a search, such that items aren't constantly replaced */ export declare class SearchCache { protected create: (...key: K) => V; protected map: TCacheMap>; protected queue: Queue; protected maxSize: number; /** * Creates a new search cache * @param create The function to create new values * @param maxSize The maximum number of items to keep in the cache */ constructor(create: (...key: K) => V, maxSize?: number); /** * Retrieves multiple items, either from the cache or newly created * @param items The keys of the items to get * @returns The items */ getAll(items: TCacheKeysList): V[]; /** * Retrieves an item, either from the cache or newly created * @param keys The keys to get the item for * @returns The item */ get(...keys: K): V; /** * Adds an item to the cache map * @param map The map to add the value to * @param keys The keys to add the value under * @param value The value to add * @param node The queue node to store in the map */ protected add(map: Map>>, [key, ...keys]: MKeys, value: V, node: IQueueNode): void; /** * Removes an item from the cache * @param map The map to add the value to * @param keys The keys to remove the value from */ protected remove(map: Map>>, [key, ...keys]: MKeys): void; } export {}; //# sourceMappingURL=SearchCache.d.ts.map