feat: ✨ add cache and cache revalidation to getHome
parent
85d8945eb1
commit
1fe7beba6f
@ -1,7 +1,12 @@
|
|||||||
import type { Options } from "node_modules/payload/dist/globals/operations/local/findOne";
|
import type { Options } from "node_modules/payload/dist/globals/operations/local/findOne";
|
||||||
import { getPayload } from "@/utils/payload";
|
import { getPayload } from "@/utils/payload";
|
||||||
|
import { unstable_cache } from "next/cache";
|
||||||
|
|
||||||
export const getHome = async (opts: Omit<Options<"home">, "slug"> = {}) => {
|
export const getHome = unstable_cache(
|
||||||
const payload = await getPayload();
|
async (opts: Omit<Options<"home">, "slug"> = {}) => {
|
||||||
return await payload.findGlobal({ slug: "home", ...opts });
|
const payload = await getPayload();
|
||||||
};
|
return await payload.findGlobal({ slug: "home", ...opts });
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
{ revalidate: 60 * 60, tags: ["home"] },
|
||||||
|
);
|
||||||
|
Loading…
Reference in New Issue