Skip to content

Commit

Permalink
Adds util for creation unstable cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
bLopata committed Dec 26, 2024
1 parent 9913c9b commit 5689368
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions www/utils/unstableCache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { cache } from 'react';
import { unstable_cache as next_unstable_cache } from 'next/cache';

export const unstable_cache = <Args extends any[], Output>(
callback: (...args: Args) => Promise<Output>,
key: string[],
options: { revalidate: number },
) => {
return cache(
next_unstable_cache(
callback as unknown as (...args: any[]) => Promise<Output>,
key,
options
)
);
};

0 comments on commit 5689368

Please sign in to comment.