UNPKG

eyeglass

Version:
42 lines 1.24 kB
import { Dict } from "./typescriptUtils"; /** * A simple caching implementation */ export declare class SimpleCache<T> { cache: Dict<T>; constructor(); /** * Returns the current cached value * * @param {String} key - they cache key to lookup * @returns {*} the cached value */ get(key: string): T | undefined; /** * Sets the cached value * * @param {String} key - they cache key to update * @param {*} value - they value to store */ set(key: string, value: T): void; /** * Whether or not the cache has a value for a given key * * @param {String} key - they cache key to lookup * @returns {Boolean} whether or not the key is set */ has(key: string): boolean; /** * Gets the current value from the cache (if it exists), otherwise invokes the callback * * @param {String} key - they cache key lookup * @param {Function} callback - the callback to be invoked when the key is not in the cache * @returns */ getOrElse(key: string, callback: () => T): T; /** * Purges the cache */ purge(): void; } //# sourceMappingURL=SimpleCache.d.ts.map