From 1a2241c40e10193c5ff7008a7b7b36cc1d855d96 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Tue, 25 Mar 2025 15:55:45 +0900 Subject: initial commit --- lib/unstable-cache.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/unstable-cache.ts (limited to 'lib/unstable-cache.ts') diff --git a/lib/unstable-cache.ts b/lib/unstable-cache.ts new file mode 100644 index 00000000..c17bb9d8 --- /dev/null +++ b/lib/unstable-cache.ts @@ -0,0 +1,19 @@ +/** + * @see https://github.com/ethanniser/NextMaster/blob/main/src/lib/unstable-cache.ts + */ + +import { cache } from "react" +import { unstable_cache as next_unstable_cache } from "next/cache" + +// next_unstable_cache doesn't handle deduplication, so we wrap it in React's cache +export const unstable_cache = ( + cb: (...args: Inputs) => Promise, + keyParts: string[], + options?: { + /** + * The revalidation interval in seconds. + */ + revalidate?: number | false + tags?: string[] + } +) => cache(next_unstable_cache(cb, keyParts, options)) -- cgit v1.2.3