From b55201c2e866b4ded613429c3ccff47df9288aa8 Mon Sep 17 00:00:00 2001 From: oof2win2 <23482862+oof2win2@users.noreply.github.com> Date: Sat, 6 Feb 2021 16:06:05 +0000 Subject: [PATCH] :bug: Fix: Cache manager didn't have proper functions --- utils/cache-manager.js | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/utils/cache-manager.js b/utils/cache-manager.js index d6ad72f..fafbdb7 100644 --- a/utils/cache-manager.js +++ b/utils/cache-manager.js @@ -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,