[CRITICAL] Cache JSON file reads in memory - eliminate full-file I/O on every query #32
Labels
No labels
blocked:needs-human
blocked:verify-failed
bug
feature-request
quickfix
security/high
security/medium
test-coverage
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/subvault#32
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Location:
backend/src/database.ts:286-410Problem: Every database query reads the entire JSON file from disk via
fs.readFileSync+JSON.parsewith no in-memory cache. This means 4-5 synchronous file reads per request.Impact: 50–100x slower data access as dataset grows. For N subscriptions and M API calls, I/O cost scales as O(N×M).
Fix: Load all 4 JSON files into memory at module init. Maintain
Map<string, User>(by id) andMap<string, User>(by email, lowercase). Same for subscriptions by id and userId. Update indexes on mutations with a write-through pattern.Effort: ~4-6 hours