38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import "server-only";
|
|
|
|
import { cacheLife, cacheTag } from "next/cache";
|
|
|
|
import { getPublicGuide, getPublicGuideSummary, listPublicGuideCards } from "@/lib/guides/queries";
|
|
import {
|
|
DIRECTORY_CACHE_TAG,
|
|
GLOSSARY_CACHE_TAG,
|
|
pageCacheTag,
|
|
} from "@/lib/cache/tags";
|
|
|
|
export async function getCachedPublicGuideCards() {
|
|
"use cache: remote";
|
|
cacheLife({ stale: 30, revalidate: 60, expire: 60 * 60 });
|
|
cacheTag(DIRECTORY_CACHE_TAG);
|
|
cacheTag(GLOSSARY_CACHE_TAG);
|
|
return listPublicGuideCards();
|
|
}
|
|
|
|
export async function getCachedPublicGuide(slug: string, section = "overview") {
|
|
"use cache: remote";
|
|
cacheLife({ stale: 15, revalidate: 60, expire: 60 * 60 });
|
|
const result = await getPublicGuide(slug, section);
|
|
cacheTag(GLOSSARY_CACHE_TAG);
|
|
cacheTag(DIRECTORY_CACHE_TAG);
|
|
if (result) cacheTag(pageCacheTag(result.id));
|
|
return result;
|
|
}
|
|
|
|
export async function getCachedPublicGuideSummary(slug: string) {
|
|
"use cache: remote";
|
|
cacheLife({ stale: 15, revalidate: 60, expire: 60 * 60 });
|
|
cacheTag(DIRECTORY_CACHE_TAG);
|
|
const result = await getPublicGuideSummary(slug);
|
|
if (result) cacheTag(pageCacheTag(result.id));
|
|
return result;
|
|
}
|