UNPKG

kbotify

Version:

kaiheila bot framework

43 lines 2.4 kB
"use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _CacheManager_guildCache; Object.defineProperty(exports, "__esModule", { value: true }); exports.CacheManager = void 0; const lru_cache_1 = __importDefault(require("lru-cache")); const bot_object_1 = require("../base/bot.object"); const cache_guild_1 = require("./cache.guild"); const options = { max: 64, maxAge: 30 * 6e4 }; class CacheManager extends bot_object_1.BaseObject { constructor(bot) { super(bot); _CacheManager_guildCache.set(this, void 0); this.guild = (id) => { let guildCache = __classPrivateFieldGet(this, _CacheManager_guildCache, "f").get(id); if (guildCache) { return guildCache; } else { guildCache = new cache_guild_1.GuildCache(id, this.client); __classPrivateFieldGet(this, _CacheManager_guildCache, "f").set(id, guildCache); return guildCache; } }; __classPrivateFieldSet(this, _CacheManager_guildCache, new lru_cache_1.default(options), "f"); } } exports.CacheManager = CacheManager; _CacheManager_guildCache = new WeakMap(); //# sourceMappingURL=cache.manager.js.map