@sap/xssec
Version:
XS Advanced Container Security API for node.js
28 lines • 1.01 kB
TypeScript
export = LRUCache;
/**
* Implements a Least Recently Used (LRU) cache using a Map.
* Due to the nature of Map, the order of insertion is preserved in keys() which allows for an implementation with average O(1) complexity for get and put.
* @param {number} capacity
*/
declare class LRUCache {
/**
* Creates an instance of LRUCache.
* @param {number} size - The maximum number of items the cache can hold.
*/
constructor(size: number);
size: number;
map: Map<any, any>;
/**
* Retrieve a value from the cache.
* @param {string} key - The key of the item to retrieve.
* @returns {*} The value associated with the key, or null if the key does not exist.
*/
get(key: string): any;
/**
* Insert or update a value in the cache.
* @param {string} key - The key of the item to insert or update.
* @param {*} value - The value to associate with the key.
*/
set(key: string, value: any): void;
}
//# sourceMappingURL=LRUCache.d.ts.map