summaryrefslogtreecommitdiff
path: root/lib/unstable-cache.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-03-26 00:37:41 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-03-26 00:37:41 +0000
commite0dfb55c5457aec489fc084c4567e791b4c65eb1 (patch)
tree68543a65d88f5afb3a0202925804103daa91bc6f /lib/unstable-cache.ts
3/25 까지의 대표님 작업사항
Diffstat (limited to 'lib/unstable-cache.ts')
-rw-r--r--lib/unstable-cache.ts19
1 files changed, 19 insertions, 0 deletions
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 = <Inputs extends unknown[], Output>(
+ cb: (...args: Inputs) => Promise<Output>,
+ keyParts: string[],
+ options?: {
+ /**
+ * The revalidation interval in seconds.
+ */
+ revalidate?: number | false
+ tags?: string[]
+ }
+) => cache(next_unstable_cache(cb, keyParts, options))