Add performance optimizations and component refactors
- Cache read-heavy public API routes via redisCache (leaderboard, values, shop, articles, photos, guilds, teams, staff, users, home, radio, badges) - Add single-flight and bounded-memory cache layer with unit tests - Parallelize independent DB queries on search, rares, shop, staff, polls and profile pages - Push radio points leaderboard aggregation to SQL with a LIMIT - Split studio-client and import-furni-client into focused modules - Clean up next.config.ts
This commit is contained in:
1 parent
54f2bc5e0c
commit
f285a7cd98
42 files changed
+1616
-1205
No files matched your search
@@ -20,3 +20,17 @@ export async function redisCache<T>(
|
||||
export function apiCacheKey(path: string): string {
|
||||
return `api:${path}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deep-convert a payload to a JSON-cache-safe form: BigInt → string (matching
|
||||
* the apiJson() wire format) and Date → ISO string, since JSON.stringify throws
|
||||
* on BigInt. Use for payloads cached through redisCache() that are serialised
|
||||
* straight to a response and never consumed by page logic.
|
||||
*/
|
||||
export function cacheSafe<T>(value: T): T {
|
||||
return JSON.parse(
|
||||
JSON.stringify(value, (_k, v) =>
|
||||
typeof v === "bigint" ? v.toString() : v,
|
||||
),
|
||||
) as T;
|
||||
}
|
||||
Reference in new issue
Block a user