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

+3
View File
@@ -18,6 +18,7 @@ import {
ensureDirectories,
IMPORTED_PAGE_CAPTION_SAVE,
importSingleFurni,
resetCatalogPageCache,
} from "@/lib/services/furni-import";
import { getOfficialHabboFurnidata } from "@/lib/services/habbo-furnidata-cache";
import { listFurniture } from "@/lib/services/habbofurni";
@@ -820,6 +821,8 @@ export const PUT = withAdmin(
}
if (!isDryRun) {
// Clear in-memory catalog page cache since we may have created/deleted pages
resetCatalogPageCache();
logAudit({
userId: ctx.session.user.id,
action: "furni_reorganize",