refactor utility functions

This commit is contained in:
Nystik
2026-06-03 01:15:27 +02:00
parent b90752e0ad
commit 05a3908a7a
10 changed files with 68 additions and 114 deletions

View File

@@ -5,19 +5,14 @@
// - 5-minute TTL per entry
// - Entries kept until TTL expires (plugins may read the same file multiple times)
import { normalize } from "../util/path.js";
const MAX_SIZE = 200 * 1024 * 1024;
const TTL_MS = 5 * 60 * 1000;
const cache = new Map(); // path -> { data, size, createdAt }
let currentSize = 0;
function normalize(p) {
return (p || "")
.replace(/\\/g, "/")
.replace(/^\/+/, "")
.replace(/\/+$/, "");
}
function evictExpired() {
const now = Date.now();