-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Conversation
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(); |
There was a problem hiding this comment.
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() }); |
There was a problem hiding this comment.
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.
for (const routeRawData of routeRawDatum) { | ||
try { | ||
routesStore.put(routeRawData); | ||
} catch (e) { | ||
// skip on invalid data | ||
continue; | ||
} | ||
} |
There was a problem hiding this comment.
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
Still ampas-tier, at least a step to #29