mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-10-27 12:36:24 -04:00
refactor: use "use cache: remote" for request-time reads and updateTag/refresh for mutations
- Replace `"use cache"` with `"use cache: remote"` on functions that run inside dynamic holes (`getContributions`, `getRepos`, `getPostStats`, `getCachedComments`) so entries are shared across server instances
- Switch comment and view server actions from `revalidatePath`/`revalidateTag` to `updateTag` + `refresh` for read-your-writes invalidation
- Extract a `commentsTag(pageSlug)` helper so each page's comment cache is expired independently instead of blowing the whole "comments" tag
- Refactor `getComments` to delegate to a cached inner function that throws on failure (so errors are never cached); `getCommentCount` now reuses that cache entry instead of issuing a separate COUNT query
- Drop `lib/data/views.ts` (`getAllViewCounts`) — the `/api/hits` route now calls `getPostStats()` instead
- Remove `revalidateTag("views")` from `incrementViews`; view counts in `getPostStats` are allowed to lag by a cache TTL
- Remove the `Suspense`/`Skeleton` wrapper on the projects page since `getContributions` is now a remote-cached call
This commit is contained in:
10 files changed
+75
-96
No files matched your search
@@ -11,7 +11,7 @@ export const getContributions = async (): Promise<
|
||||
level: number;
|
||||
}>
|
||||
> => {
|
||||
"use cache";
|
||||
"use cache: remote";
|
||||
cacheLife("minutes");
|
||||
|
||||
// thanks @grubersjoe! :) https://github.com/grubersjoe/github-contributions-api/blob/main/src/scrape.ts
|
||||
@@ -81,7 +81,7 @@ export const getContributions = async (): Promise<
|
||||
};
|
||||
|
||||
export const getRepos = async (): Promise<Repository[] | undefined> => {
|
||||
"use cache";
|
||||
"use cache: remote";
|
||||
cacheLife("minutes");
|
||||
|
||||
try {
|
||||
|
||||
+9
-12
@@ -7,7 +7,6 @@ import { PageTitle } from "@/components/layout/page-title";
|
||||
import { FadeTransition } from "@/components/page-transition";
|
||||
import { RelativeTime } from "@/components/relative-time";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { createMetadata } from "@/lib/metadata";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
@@ -45,17 +44,15 @@ const Page = async () => {
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<Suspense fallback={<Skeleton className="h-40 w-full" />}>
|
||||
{contributions.length > 0 ? (
|
||||
<div className={cn("mx-auto mt-4 mb-8")}>
|
||||
<ActivityCalendar data={contributions} noun="contribution" />
|
||||
</div>
|
||||
) : (
|
||||
<p className="my-4 text-center text-muted-foreground">
|
||||
Unable to load contribution data at this time.
|
||||
</p>
|
||||
)}
|
||||
</Suspense>
|
||||
{contributions.length > 0 ? (
|
||||
<div className={cn("mx-auto mt-4 mb-8")}>
|
||||
<ActivityCalendar data={contributions} noun="contribution" />
|
||||
</div>
|
||||
) : (
|
||||
<p className="my-4 text-center text-muted-foreground">
|
||||
Unable to load contribution data at this time.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<h2 className="my-3.5 text-lg font-medium">
|
||||
<a
|
||||
|
||||
Reference in new issue
Block a user