UNPKG

@naturalcycles/nodejs-lib

Version:
33 lines (32 loc) 639 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LRUMemoCache = void 0; const LRUCache = require("lru-cache"); /** * @example * Use it like this: * * @_Memo({ cacheFactory: () => new LRUMemoCache({...}) }) * method1 () */ class LRUMemoCache { constructor(opt) { this.lru = new LRUCache({ max: 100, ...opt, }); } has(k) { return this.lru.has(k); } get(k) { return this.lru.get(k); } set(k, v) { this.lru.set(k, v); } clear() { this.lru.clear(); } } exports.LRUMemoCache = LRUMemoCache;