Skip to content

Commit

Permalink
🐛 Fix: Cache manager didn't have proper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
oof2win2 committed Feb 6, 2021
1 parent 4587f76 commit b55201c
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions utils/cache-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,46 @@ class CacheManagerClass {
this._cache = new NodeCache(opts);
}
get(key) {
return this._cache.get(key);
try {
return this._cache.get(key);
} catch (error) {
ErrorManager.error(error)
}
}
set(key, obj, timeout) {
const res = this._cache.set(key, obj, timeout);
if (res === false) {
ErrorManager.Error("Cache not behaving correctly. Didn't set value");
} else {
return true;
try {
const res = this._cache.set(key, obj, timeout);
if (res === false) {
ErrorManager.Error("Cache not behaving correctly. Didn't set value");
} else {
return true;
}
} catch (error) {
ErrorManager.Error(error);
}
}
take(key) {
try {
return this._cache.take(key);
} catch (error) {
ErrorManager.Error(error)
}
}
del(key) {
try {
return this._cache.del(key);
} catch (error) {
ErrorManager.Error(error)
}
}
has(key) {
try {
return this._cache.has(key)
} catch (error) {
ErrorManager.Error(error)
}
}

}
let CacheManager = new CacheManagerClass({
checkperiod: 120,
Expand Down

0 comments on commit b55201c

Please sign in to comment.