mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 11:01:45 +00:00
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:
@@ -1,6 +1,6 @@
|
||||
import { getDay } from "date-fns";
|
||||
import { and, eq, inArray, isNull, ne, or, sql } from "drizzle-orm";
|
||||
import { unstable_cache } from "next/cache";
|
||||
import { cacheLife, cacheTag } from "next/cache";
|
||||
import {
|
||||
budgets,
|
||||
cards,
|
||||
@@ -481,13 +481,9 @@ async function aggregateMonthDataInternal(userId: string, period: string) {
|
||||
};
|
||||
}
|
||||
|
||||
export function aggregateMonthData(userId: string, period: string) {
|
||||
return unstable_cache(
|
||||
() => aggregateMonthDataInternal(userId, period),
|
||||
[`insights-aggregate-${userId}-${period}`],
|
||||
{
|
||||
tags: [`dashboard-${userId}`],
|
||||
revalidate: 60,
|
||||
},
|
||||
)();
|
||||
export async function aggregateMonthData(userId: string, period: string) {
|
||||
"use cache";
|
||||
cacheTag(`dashboard-${userId}`);
|
||||
cacheLife({ revalidate: 3 });
|
||||
return aggregateMonthDataInternal(userId, period);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user