Files
bunext/dist/functions/cache/grab-cache-names.js
2026-10-13 15:52:34 +01:00

10 lines
484 B
JavaScript

export default function grabCacheNames({ key, cache_id, paradigm = "html", }) {
// Hashing keeps file names short and fixed-length no matter how long
// the request path or query string is.
const parsed_key = cache_id ||
new Bun.CryptoHasher("sha256").update(key || "").digest("hex");
const cache_name = `${parsed_key}.res.${paradigm}`;
const cache_meta_name = `${parsed_key}.meta.json`;
return { cache_id: parsed_key, cache_name, cache_meta_name };
}