Files
NapCatQQ/.pnpm-store/v3/files/61/407cc3d13d435650f24ac03a2c098a7660ce5074d9c05319533265baa98f97f9b3ece603c39150c3094d46f5129823cc845befc0599f8358f745b1db011595
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

37 lines
1.0 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setCache = exports.getCache = exports.clearCache = void 0;
var _tslib = require("tslib");
var cache = new Map();
var setCache = exports.setCache = function setCache(key, cacheTime, cachedData) {
var currentCache = cache.get(key);
if (currentCache === null || currentCache === void 0 ? void 0 : currentCache.timer) {
clearTimeout(currentCache.timer);
}
var timer = undefined;
if (cacheTime > -1) {
// if cache out, clear it
timer = setTimeout(function () {
cache["delete"](key);
}, cacheTime);
}
cache.set(key, (0, _tslib.__assign)((0, _tslib.__assign)({}, cachedData), {
timer: timer
}));
};
var getCache = exports.getCache = function getCache(key) {
return cache.get(key);
};
var clearCache = exports.clearCache = function clearCache(key) {
if (key) {
var cacheKeys = Array.isArray(key) ? key : [key];
cacheKeys.forEach(function (cacheKey) {
return cache["delete"](cacheKey);
});
} else {
cache.clear();
}
};