Skip to content

Commit

Permalink
Merge pull request #77 from oof2win2/master
Browse files Browse the repository at this point in the history
Bugfix: Cache manager didn't have proper functions
  • Loading branch information
DistroByte authored Feb 8, 2021
2 parents 4587f76 + b55201c commit bb1bbd9
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 bb1bbd9

Please sign in to comment.