UNPKG

@rapidthenerd/ergast-ts

Version:

Node wrapper for Ergast API

41 lines (40 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Cache = void 0; var NodeCache = require("node-cache"); var Cache = exports.Cache = /** @class */ (function () { function Cache() { } Cache.getCache = function () { return this.cache; }; Cache.isEnabled = function () { return this.config.useCache; }; Cache.isInCache = function (key) { return this.cache.get(key) != null; }; Cache.get = function (key) { return this.cache.get(key); }; Cache.set = function (key, obj) { this.cache.set(key, obj); }; Cache.generateKey = function (className) { var params = []; for (var _i = 1; _i < arguments.length; _i++) { params[_i - 1] = arguments[_i]; } var base = "cache_" + className + "_"; for (var _b = 0, params_1 = params; _b < params_1.length; _b++) { var param = params_1[_b]; base += param + "_"; } return base; }; var _a; _a = Cache; Cache.config = require('../config.js'); Cache.cache = new NodeCache({ stdTTL: _a.config.cacheTimeOut, checkperiod: _a.config.cacheCheckPeriod }); return Cache; }());