Skip to content

Commit

Permalink
perf: add caches to prevent excess memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuhito committed Apr 29, 2023
1 parent 7203e3a commit 67c2ac9
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 66 deletions.
113 changes: 78 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions website/app/routes/actions/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import invariant from 'tiny-invariant';

import { updateAlgoliaIndex } from '@/utils/algolia.server';
import { updateDownloadCount } from '@/utils/metadata/download.server';
import { updateAllMetadata } from '@/utils/metadata/metadata.server';
import {
metadataQueue,
updateAllMetadata,
updateSingleMetadata,
} from '@/utils/metadata/metadata.server';
import { updateAxisRegistry } from '@/utils/metadata/variable.server';

interface UpdateData {
Expand Down Expand Up @@ -35,7 +39,9 @@ export const action: ActionFunction = async ({ request }) => {
console.log('Updating fonts');
if (Array.isArray(data.fonts)) {
console.log(`Updating ${data.fonts.length} fonts`);
await updateAllMetadata(data.fonts);
for (const id of data.fonts) {
metadataQueue.add(async () => await updateSingleMetadata(id));
}
} else {
console.log('Updating all fonts');
await updateAllMetadata();
Expand Down
2 changes: 1 addition & 1 deletion website/app/utils/algolia.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const updateAlgoliaIndex = async (force?: boolean) => {
let metadata = await getMetadata(id);

if (!metadata) {
await updateAllMetadata([id]);
await updateAllMetadata();
metadata = await getMetadata(id);
}

Expand Down

0 comments on commit 67c2ac9

Please sign in to comment.