UNPKG

asksuite-core

Version:
30 lines (23 loc) 520 B
const _ = require('lodash'); const Singleton = require('./Singleton'); module.exports = class Cache extends Singleton { constructor() { super(); if (this.constructor === Cache) { throw new TypeError('Abstract class "Cache" cannot be instantiated directly.'); } this.store = {}; } set(key, value) { this.store[key] = value; } remove(key) { delete this.store[key]; } get(key) { return this.store[key]; } getStoreCopy() { return _.cloneDeep(this.store); } };