mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 14:32:04 +00:00
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.SimpleCache = void 0;
|
|
class SimpleCache {
|
|
constructor() {
|
|
this.cache = new Map();
|
|
this.cleanupTimer = null;
|
|
this.cleanupTimer = setInterval(() => {
|
|
const now = Date.now();
|
|
for (const [key, item] of this.cache.entries()) {
|
|
if (item.expires < now)
|
|
this.cache.delete(key);
|
|
}
|
|
}, 60000);
|
|
}
|
|
get(key) {
|
|
const item = this.cache.get(key);
|
|
if (!item || item.expires < Date.now()) {
|
|
this.cache.delete(key);
|
|
return null;
|
|
}
|
|
return item.data;
|
|
}
|
|
set(key, data, ttlSeconds = 300) {
|
|
this.cache.set(key, {
|
|
data,
|
|
expires: Date.now() + (ttlSeconds * 1000)
|
|
});
|
|
}
|
|
clear() {
|
|
this.cache.clear();
|
|
}
|
|
destroy() {
|
|
if (this.cleanupTimer) {
|
|
clearInterval(this.cleanupTimer);
|
|
this.cleanupTimer = null;
|
|
}
|
|
this.cache.clear();
|
|
}
|
|
}
|
|
exports.SimpleCache = SimpleCache;
|
|
//# sourceMappingURL=simple-cache.js.map
|