perf(cache): migração para diretiva use cache do Next.js

Todas as queries cacheadas do dashboard migram de `unstable_cache` para
a diretiva `use cache` com `cacheTag` e `cacheLife({ revalidate: 3 })`.

Todas as páginas e o layout do dashboard passam a chamar `connection()`
para garantir renderização dinâmica. O root layout envolve os filhos em
`<Suspense>`. `next.config.ts` remove `turbopackFileSystemCacheForDev`
e adota `cacheComponents: true`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Felipe Coutinho
2026-04-01 14:14:23 +00:00
parent 96df6a1798
commit e32fb85006
30 changed files with 86 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
import { unstable_cache } from "next/cache";
import { cacheLife, cacheTag } from "next/cache";
import { fetchDashboardData } from "@/features/dashboard/fetch-dashboard-data";
import { fetchUserDashboardPreferences } from "@/features/dashboard/preferences-queries";
import {
@@ -52,15 +52,11 @@ async function fetchDashboardQuickActionOptionsInternal(
};
}
export function fetchDashboardQuickActionOptions(userId: string) {
return unstable_cache(
() => fetchDashboardQuickActionOptionsInternal(userId),
[`dashboard-quick-actions-${userId}`],
{
tags: [`dashboard-${userId}`],
revalidate: 60,
},
)();
export async function fetchDashboardQuickActionOptions(userId: string) {
"use cache";
cacheTag(`dashboard-${userId}`);
cacheLife({ revalidate: 3 });
return fetchDashboardQuickActionOptionsInternal(userId);
}
export async function fetchDashboardPageData(userId: string, period: string) {