Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexedDB Caching #31

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

IndexedDB Caching #31

wants to merge 6 commits into from

Conversation

stevemc4
Copy link
Collaborator

Still ampas-tier, at least a step to #29

const meta = await getAll<{ key: string, value: string | number }>(db, "meta");
const expireAt = meta.find((item) => item.key === "expireAt")?.value;
if (expireAt === undefined) return true;
return (expireAt as number) > new Date().getTime();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be?

(expireAt as number) < new Date().getTime();

}

const metaStore = tx.objectStore("meta");
metaStore.put({ key: "expireAt", value: new Date().getTime() });
Copy link
Member

@andraantariksa andraantariksa Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the expiry need to be added with some values. I guess 6 hours is enough.

Comment on lines +100 to +107
for (const routeRawData of routeRawDatum) {
try {
routesStore.put(routeRawData);
} catch (e) {
// skip on invalid data
continue;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cancel the transaction if any data is not valid 👍 , we dont want any missing data in cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants