perf: optimize import batch performance with caching + validation
CI / check (push) Successful in 32s
CI / release (push) Skipped
CI / deploy (push) Successful in 59s

Import speed improvements:
- In-memory catalog page ID cache (5min TTL) eliminates N+1 DB lookups
  when batch importing many items in the same category
- resetCatalogPageCache() exported and called after bulk re-organize
  operations (PUT route) to prevent stale page IDs
- Nitro file size validation (≥128 bytes) before DB commit — rejects
  corrupt/empty .nitro files that would break the client
- batchLookupByClassnames now uses Promise.all for parallel cache lookups
  instead of sequential awaits (10x faster for 50+ items)
- Auto-cleanup of corrupt nitro files on validation failure
This commit is contained in:
openhands committed 2026-08-06 20:27:06 +02:00
1 parent a1775fbf1e
commit aee099339c
3 files changed
+76 -14

No files matched your search

+8 -5
View File
@@ -154,11 +154,14 @@ export async function batchLookupByClassnames(
const result = new Map<string, HabboFurniItem>();
if (classnames.length === 0) return result;
for (const cn of classnames) {
const item = await getFurnitureByClassname(cn);
if (item?.name) {
result.set(cn, item);
}
// Parallel lookup — all share the same in-memory furnidata cache
const lookedUp = await Promise.all(
classnames.map((cn) => getFurnitureByClassname(cn)),
);
for (let i = 0; i < classnames.length; i++) {
const item = lookedUp[i];
if (item?.name) result.set(classnames[i], item);
}
return result;