UNPKG

slim-cache

Version:

Super Fast Lightweight Cache with a Map like interface

87 lines (86 loc) 1.63 kB
/*! * slim-cache <https://github.com/nivrith/slim-cache> * * Copyright (c) Nivrith Mandayam Gomatam * Licensed under the MIT License. */ /** * * * @export * @class SlimCache * */ export interface CacheList { key: keyof any; value: any; } export declare class SlimCache { /** * The cache instance * * @private * @type {*} * @memberof SlimCache */ private cache; /** *Creates an instance of SlimCache. * @param {*} cache Preferably an Object Without Prototype * @memberof SlimCache */ constructor(cache?: any); /** * * * @param {keyof any} key * @returns * @memberof SlimCache */ has(key: keyof any): boolean; /** * * * @param {keyof any} key * @param {*} value * @memberof SlimCache */ set(key: keyof any, value: any): void; /** * * * @param {keyof any} key * @returns {*} * @memberof SlimCache */ get(key: keyof any): any; /** * * * @param {keyof any} key * @returns {Boolean} Returns `true` if the entry was removed successfully, else `false`. * @memberof SlimCache */ clear(key: keyof any): boolean; /** Replace internal map cache with a fresh one * * * @param {*} [cache=Object.create(null)] * @memberof SlimCache */ flush(cache?: any): void; /** * * * @memberof SlimCache */ clean(): void; /** * * * @returns {boolean} * @memberof SlimCache */ isEmpty(): boolean; } export default SlimCache;