UNPKG

639 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({
15 max: 100,
16 ...opt,
17 });
18 }
19 has(k) {
20 return this.lru.has(k);
21 }
22 get(k) {
23 return this.lru.get(k);
24 }
25 set(k, v) {
26 this.lru.set(k, v);
27 }
28 clear() {
29 this.lru.clear();
30 }
31}
32exports.LRUMemoCache = LRUMemoCache;