-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcache.js
More file actions
44 lines (39 loc) · 719 Bytes
/
cache.js
File metadata and controls
44 lines (39 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const Immutable = require("immutable");
const SimpleObjectCache = {
init() {
let cache = {};
return {
hits: 0,
set(key, value) {
cache[key] = value;
},
get(key) {
this.hits++;
return cache[key];
},
has(key) {
return !!cache[key];
}
};
}
};
const ImmutableListCache = {
init() {
let map = Immutable.Map();
return {
hits: 0,
set(key, value) {
map = map.set(key, value);
},
get(key) {
this.hits++;
return map.get(key);
},
has(key) {
return map.has(key);
}
};
}
};
//export default SimpleObjectCache;
module.exports = ImmutableListCache;