Skip to content

Commit bb1bbd9

Browse files
authored
Merge pull request #77 from oof2win2/master
Bugfix: Cache manager didn't have proper functions
2 parents 4587f76 + b55201c commit bb1bbd9

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

utils/cache-manager.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,46 @@ class CacheManagerClass {
66
this._cache = new NodeCache(opts);
77
}
88
get(key) {
9-
return this._cache.get(key);
9+
try {
10+
return this._cache.get(key);
11+
} catch (error) {
12+
ErrorManager.error(error)
13+
}
1014
}
1115
set(key, obj, timeout) {
12-
const res = this._cache.set(key, obj, timeout);
13-
if (res === false) {
14-
ErrorManager.Error("Cache not behaving correctly. Didn't set value");
15-
} else {
16-
return true;
16+
try {
17+
const res = this._cache.set(key, obj, timeout);
18+
if (res === false) {
19+
ErrorManager.Error("Cache not behaving correctly. Didn't set value");
20+
} else {
21+
return true;
22+
}
23+
} catch (error) {
24+
ErrorManager.Error(error);
25+
}
26+
}
27+
take(key) {
28+
try {
29+
return this._cache.take(key);
30+
} catch (error) {
31+
ErrorManager.Error(error)
32+
}
33+
}
34+
del(key) {
35+
try {
36+
return this._cache.del(key);
37+
} catch (error) {
38+
ErrorManager.Error(error)
39+
}
40+
}
41+
has(key) {
42+
try {
43+
return this._cache.has(key)
44+
} catch (error) {
45+
ErrorManager.Error(error)
1746
}
1847
}
48+
1949
}
2050
let CacheManager = new CacheManagerClass({
2151
checkperiod: 120,

0 commit comments

Comments
 (0)