Files
NapCatQQ/.pnpm-store/v3/files/18/9c8ef1f829e42edade35be905738a4d121c23d27d62af4ef9dfd4a59e840b92479fba9f5dd619a770f5133f20434c829953e124e0c9d4ed658a87ea9e48e99
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

30 lines
898 B
Plaintext

import { __assign } from "tslib";
var cache = new Map();
var setCache = function (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, __assign(__assign({}, cachedData), { timer: timer }));
};
var getCache = function (key) {
return cache.get(key);
};
var clearCache = function (key) {
if (key) {
var cacheKeys = Array.isArray(key) ? key : [key];
cacheKeys.forEach(function (cacheKey) { return cache.delete(cacheKey); });
}
else {
cache.clear();
}
};
export { getCache, setCache, clearCache };