feat(list): add caching
Build and Deploy / build-and-deploy (push) Successful in 2m7s

This commit is contained in:
2026-06-26 16:37:16 +07:00 Unverified
parent 0cf91d886f
commit 532a3314a5
+18 -1
View File
@@ -151,7 +151,18 @@ export function card(app: App) {
if (debug) return { data };
return ListPage(
const cacheKey = hash(
JSON.stringify({
data,
lang,
}),
).toString(36);
if (feature("API")) {
const cached = cache.get<ImageResponse>(cacheKey);
if (cached) return cached.clone();
}
const res = await ListPage(
data,
pfps[`${data.playerInfo.profilePicture.id ?? 1}`]?.IconPath,
namecards[`${data.playerInfo.nameCardId ?? 210001}`]?.Icon,
@@ -160,6 +171,12 @@ export function card(app: App) {
locs[lang ?? "en"],
log,
);
queueMicrotask(() => {
cache.set(cacheKey, res, 1000 * 60 * 60 * 24); // cache for 24 hour
});
return res.clone();
} catch (err) {
if (err instanceof InvalidFormatError)
return error(400, errorLoc.uidFormat);