"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeCache = void 0;
const node_cache_1 = __importDefault(require("node-cache"));
class NodeCache {
    // eslint-disable-next-line @typescript-eslint/no-empty-function
    constructor() { }
    static createInstance(params = {}) {
        if (!NodeCache.instance) {
            const options = {
                ...NodeCache.defaultOptions,
                ...params,
            };
            NodeCache.instance = new node_cache_1.default(options);
        }
        return NodeCache.instance;
    }
}
exports.NodeCache = NodeCache;
NodeCache.defaultOptions = {
    stdTTL: 3600,
    checkperiod: 1200,
};
NodeCache.init = (params) => {
    const nodeCache = NodeCache.createInstance(params);
    global.app = { nodeCache };
};
NodeCache.getInstance = () => {
    const nodeCache = global.app?.cache ?? NodeCache.createInstance();
    return nodeCache;
};
NodeCache.getCachedData = () => {
    const nodeCache = NodeCache.getInstance();
    return nodeCache.data;
};
NodeCache.get = (key) => {
    const nodeCache = NodeCache.getInstance();
    const value = nodeCache.get(key) ?? '';
    return value;
};
//# sourceMappingURL=node-cache.js.map