@naturalcycles/nodejs-lib
Version:
Standard library for Node.js
30 lines (29 loc) • 511 B
JavaScript
import { LRUCache } from 'lru-cache';
/**
* @example
* Use it like this:
*
* `@_Memo({ cacheFactory: () => new LRUMemoCache({...}) })`
* method1 ()
*/
export class LRUMemoCache {
constructor(opt) {
this.lru = new LRUCache({
max: 100,
...opt,
});
}
lru;
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();
}
}