Skip to content

Commit bde6e06

Browse files
committed
chore: test use cache
1 parent b9eaee7 commit bde6e06

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

apps/insights/src/server/pyth.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { unstable_cache } from "next/cache";
21
import { parse,stringify } from "superjson";
32
import { 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

6765
export 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

9390
export const getFeedForSymbolCached = async ({symbol, cluster = Cluster.Pythnet}: {symbol: string, cluster?: Cluster}) => {
9491
const start = Date.now();

0 commit comments

Comments
 (0)