1 | export default function Cache() {
|
2 | this.active = true;
|
3 | this.data = new Map();
|
4 | }
|
5 |
|
6 | Cache.prototype = {
|
7 | constructor: Cache,
|
8 | set(key, value) {
|
9 | if (this.active) this.data.set(key, value);
|
10 | },
|
11 | get(key) {
|
12 | if (this.active) return this.data.get(key);
|
13 | },
|
14 | has(key) {
|
15 | if (this.active) return this.data.has(key);
|
16 | return false;
|
17 | },
|
18 | clear() {
|
19 | return this.data.clear();
|
20 | },
|
21 | delete(key) {
|
22 | return this.data.delete(key);
|
23 | }
|
24 | };
|