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
@@ -3,7 +3,7 @@ import { apiJson } from "@/lib/api";
|
||||
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
|
||||
import { db, User, WebsiteArticles } from "@/lib/db";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { apiCacheKey, redisCache } from "@/lib/redis-cache";
|
||||
import { apiCacheKey, cacheSafe, redisCache } from "@/lib/redis-cache";
|
||||
|
||||
/**
|
||||
* GET /api/home — combined landing payload: the latest 4 website_articles and
|
||||
@@ -29,7 +29,11 @@ export async function GET(_req: Request) {
|
||||
db.select({ total: count() }).from(User).where(eq(User.online, "1")),
|
||||
resolveHotelName(),
|
||||
]);
|
||||
return { articles, online: onlineRows[0]?.total ?? 0, hotelName };
|
||||
return cacheSafe({
|
||||
articles,
|
||||
online: onlineRows[0]?.total ?? 0,
|
||||
hotelName,
|
||||
});
|
||||
});
|
||||
return apiJson(data);
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user