v1.4.0: Fix Vercel deployment, security headers, rate limiter, cache cleanup

This commit is contained in:
Sʜɪɴᴇɪ Nᴏᴜᴢᴇɴ
2026-06-25 00:52:26 +05:30
parent 68f7ea7cf4
commit 3a28c4d182
7 changed files with 42 additions and 15 deletions
+9
View File
@@ -104,6 +104,15 @@ const setCache = (key, data, ttl = DEFAULT_TTL) => {
cache.delete(firstKey);
}
// NOTE: Periodic cleanup — prune all expired entries when cache reaches 80% capacity
// Prevents unbounded memory growth from stale entries that were never accessed
if (cache.size >= MAX_CACHE_SIZE * 0.8) {
const now = Date.now();
for (const [k, v] of cache) {
if (now > v.expiry) cache.delete(k);
}
}
cache.set(key, { data, expiry: Date.now() + ttl });
};