"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Class which holds helper tools when working with cache.
*
* @export
* @class CacheUtil
*/
var CacheUtil = (function () {
function CacheUtil() {
this.cache = {};
}
/**
* Add new key/value pair in cache
* @param {string} primeKey - primary identicator
* @param {string} key - unique string value
* @param {Everything} value - value object to be added in cache
*/
CacheUtil.prototype.add = function (primeKey, key, value) {
if (!this.cache[primeKey]) {
this.cache[primeKey] = (_a = {}, _a[key] = value, _a);
}
else {
this.cache[primeKey][key] = value;
}
var _a;
};
/**
* Get data by key from cache
* @param {string} primeKey - primary identicator
* @param {string} key - key saved in cache
* @return {*} value out of cache
*/
CacheUtil.prototype.get = function (primeKey, key) {
if ((primeKey && key) && this.cache[primeKey]) {
return this.cache[primeKey][key];
}
return false;
};
/**
* Get cache information by prime key
* @param {string} primeKey key where to get the cache from
* @return {*} get cache at prime key
*/
CacheUtil.prototype.getByPrimeKey = function (primeKey) {
return this.cache[primeKey];
};
return CacheUtil;
}());
exports.CacheUtil = CacheUtil;
exports.default = new CacheUtil();
|