28 lines
774 B
TypeScript
28 lines
774 B
TypeScript
import "server-only";
|
|
|
|
import { cacheLife, cacheTag } from "next/cache";
|
|
|
|
import { getPublicGuide, 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) {
|
|
"use cache: remote";
|
|
cacheLife({ stale: 15, revalidate: 60, expire: 60 * 60 });
|
|
const result = await getPublicGuide(slug);
|
|
cacheTag(GLOSSARY_CACHE_TAG);
|
|
if (result) cacheTag(pageCacheTag(result.id));
|
|
return result;
|
|
}
|