mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 05:23:08 +00:00
chore: add pre-built dist folder for npx usage
This commit is contained in:
committed by
Romuald Członkowski
parent
a70d96a373
commit
5057481e70
42
dist/utils/simple-cache.js
vendored
Normal file
42
dist/utils/simple-cache.js
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"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
|
||||
Reference in New Issue
Block a user