1- import { unstable_cache } from "next/cache" ;
21import { parse , stringify } from "superjson" ;
32import { z } from "zod" ;
43
@@ -38,7 +37,8 @@ export async function getFeedsForPublisherCached(
3837 return parse < z . infer < typeof priceFeedsSchema > > ( rawData ) ;
3938}
4039
41- const _privateGetFeeds = unstable_cache ( async ( cluster : Cluster ) => {
40+ const _privateGetFeeds = async ( cluster : Cluster ) => {
41+ 'use cache'
4242 const start = Date . now ( ) ;
4343 await new Promise ( ( resolve ) => setTimeout ( resolve , 10_000 ) ) ;
4444 const feeds = await _getFeedsCached ( cluster ) as Omit < z . infer < typeof priceFeedsSchema > [ number ] , 'price' > [ ] ;
@@ -60,9 +60,7 @@ const _privateGetFeeds =unstable_cache(async (cluster: Cluster) => {
6060 // const dataJson = await data.text();
6161 // const feeds: Omit<z.infer<typeof priceFeedsSchema>[0], "price">[] = parse(dataJson);
6262 // return feeds;
63- } , [ 'getFeedsCached__' ] , {
64- revalidate : DEFAULT_CACHE_TTL ,
65- } ) ;
63+ }
6664
6765export const getFeedsCached = async ( cluster : Cluster ) => {
6866 const start = Date . now ( ) ;
@@ -81,14 +79,13 @@ const _getFeedsForSymbol = async (symbol: string, cluster: Cluster) => {
8179
8280
8381
84- export const getFeedForSymbol = unstable_cache ( async ( { symbol, cluster = Cluster . Pythnet } : { symbol : string , cluster ?: Cluster } ) => {
82+ export const getFeedForSymbol = async ( { symbol, cluster = Cluster . Pythnet } : { symbol : string , cluster ?: Cluster } ) => {
83+ 'use cache'
8584 const data = await _getFeedsForSymbol ( symbol , cluster ) ;
8685 await new Promise ( ( resolve ) => setTimeout ( resolve , 10_000 ) ) ;
8786
8887 return stringify ( data ) ;
89- } , [ 'getFeedForSymbolCached__' ] , {
90- revalidate : DEFAULT_CACHE_TTL ,
91- } ) ;
88+ }
9289
9390export const getFeedForSymbolCached = async ( { symbol, cluster = Cluster . Pythnet } : { symbol : string , cluster ?: Cluster } ) => {
9491 const start = Date . now ( ) ;
0 commit comments