Skip to content

Commit ca16ed8

Browse files
committed
fix: add cache buffer
1 parent 90b3668 commit ca16ed8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/insights/src/server/pyth.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Cluster, clients, priceFeedsSchema } from "../services/pyth";
99
const getDataCached = cache(async (cluster: Cluster) => {
1010
return clients[cluster].getData();
1111
});
12-
const MAX_CACHE_SIZE_STRING = 2 * 1024 * 1024;
12+
const MAX_CACHE_SIZE_STRING = 2 * 1024 * 1024 - 510_000; // is the buffer for the returned object and the metadata from next
1313

1414
const getPublishersForFeed = unstable_cache(async (cluster: Cluster, chunk?: number) => {
1515
const data = await getDataCached(cluster);
@@ -63,6 +63,10 @@ const _getFeeds = unstable_cache(async (cluster: Cluster, chunk?: number) => {
6363
for(let i = 0; i < chunksNumber; i++) {
6464
chunks.push(result.slice(i * MAX_CACHE_SIZE_STRING, (i + 1) * MAX_CACHE_SIZE_STRING));
6565
}
66+
console.log('size',JSON.stringify({
67+
chunk: chunks[chunk ?? 0],
68+
chunksNumber,
69+
}).length)
6670
return {
6771
chunk: chunks[chunk ?? 0],
6872
chunksNumber,

0 commit comments

Comments
 (0)