Skip to content

Commit

Permalink
Add caching to filecoin page
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Brown committed Jan 13, 2025
1 parent 0bd85f0 commit 9ca204d
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import cached from '$lib/utils/cache/remote/cached';
import queryCacheKey from '$lib/utils/cache/remote/query-cache-key';
import { fetchBlogPosts } from '../../../../../lib/utils/blog-posts';
import { createFetchProjectsParameters, fetchProjects } from './load-projects';
import { redis } from '../../../../api/redis';
import { createFetchProjectsParameters, fetchProjects, fetchProjectsQuery } from './load-projects';

export default async function loadFilecoinExporePageData(f: typeof fetch) {
const projectsParameters = createFetchProjectsParameters();
const cacheKey = queryCacheKey(
fetchProjectsQuery,
[Object.entries(projectsParameters)],
'explore-page-filecoin',
);

const [blogPosts, projects] = await Promise.all([
fetchBlogPosts(),
fetchProjects(f, projectsParameters),
]);
const [blogPosts, projects] = await cached(
redis,
cacheKey,
6 * 60 * 60, // Change the cache expiration time to 6 hours
async () => Promise.all([fetchBlogPosts(), fetchProjects(f, projectsParameters)]),
);

return {
blogPosts,
Expand Down

0 comments on commit 9ca204d

Please sign in to comment.