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

Invalidate old cache versions #56

Merged
merged 4 commits into from
Jul 18, 2023
Merged

Conversation

ItsVipra
Copy link
Owner

Currently, whenever we publish a new version old cache entries stay around, potentially breaking things.
To mitigate this issue, check with which version a cache entry was created and refresh if it's not the same.

Copy link
Contributor

@nachtjasmin nachtjasmin left a comment

Choose a reason for hiding this comment

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

Since you're touching the cache code anyway, I left some recommendations to improve the structure ^^

@@ -1,5 +1,7 @@
import { debug, error } from "./logging";
import { storage } from "webextension-polyfill";
import Browser, { storage } from "webextension-polyfill";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import Browser, { storage } from "webextension-polyfill";
import { runtime, storage } from "webextension-polyfill";

I'm not sure whether importing the whole Browser object messes with the tree shaking. I think it'd be better to just import the runtime part of it and adjust the code in the rest of the file accordingly.

@@ -21,26 +23,24 @@ export async function fetchPronouns(dataID, accountName, type) {
debug(cacheResult);
// Extract the current cache by using object destructuring.
if (accountName in cacheResult.pronounsCache) {
const { value, timestamp } = cacheResult.pronounsCache[accountName];
const { value, timestamp, version } = cacheResult.pronounsCache[accountName];
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point we really shouldn't implement cache logic in this file anymore, otherwise it becomes way to messy once we want to support other pages.

Would be kind if you could extract it into the caching lib.

@nachtjasmin nachtjasmin self-requested a review July 18, 2023 17:58
@nachtjasmin nachtjasmin merged commit 25d0280 into main Jul 18, 2023
3 checks passed
@nachtjasmin nachtjasmin deleted the invalidate-old-cache-versions branch July 18, 2023 19:47
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.

None yet

2 participants