UNPKG

589 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.LRUMemoCache = void 0;
4const LRUCache = require("lru-cache");
5/**
6 * @example
7 * Use it like this:
8 *
9 * @_Memo({ cacheFactory: () => new LRUMemoCache({...}) })
10 * method1 ()
11 */
12class LRUMemoCache {
13 constructor(opt) {
14 this.lru = new LRUCache(opt);
15 }
16 has(k) {
17 return this.lru.has(k);
18 }
19 get(k) {
20 return this.lru.get(k);
21 }
22 set(k, v) {
23 this.lru.set(k, v);
24 }
25 clear() {
26 this.lru.reset();
27 }
28}
29exports.LRUMemoCache = LRUMemoCache;