sindresorhus/refined-github

Incorrect amount of bugs shown (due to cache) #2889

szmarczak posted onGitHub


Cache. It expires within an hour and is refreshed in the next pageload

posted by fregante about 5 years ago

Well then it should update when somebody clicks on the tab, right?

posted by szmarczak about 5 years ago

I’m thinking of changing the cache API so that you could set the cache manually in these cases. For example:

const countBugs = cache.function(…, {options});

…

if (isBugsPage) {
  countBugs.set(getCountFromDom()); // this sets the cache using the options already defined for cache.function
  // instead of
  // const key = xxx
  // const expiration = maxAge + staleWhileRevalidate
  // await cache.set(key, getCountFromDom(), expiration)
}

const bugs = await countBugs()

cc @sindresorhus a new API isn’t strictly necessary, but it helps reuse the logic/options without having to manually create additional constants.

API suggestions welcome

posted by fregante about 5 years ago

Cache. It expires within an hour and is refreshed in the next pageload

It never expires on my side. It has been days and I'm still seeing 1. Reload doesn't do anything.

posted by szmarczak about 5 years ago

Chrome or Firefox?

Try this in the background script inspector

await browser.storage.get('bugs-tab:szmarczak/cacheable-lookup')

What’s the result of this?

posted by fregante about 5 years ago

The cache should be there for 4 days, but if you reload the page twice after half an hour it should be expired/updated. So if you load the page now it should definitely show 0, otherwise it’s not working as expected

posted by fregante about 5 years ago

Chrome or Firefox?

Chrome.

image

So if you load the page now it should definitely show 0, otherwise it’s not working as expected

It still shows 1.

posted by szmarczak about 5 years ago

My bad,

await browser.storage.local.get('bugs-tab:szmarczak/cacheable-lookup')
posted by fregante about 5 years ago

image

posted by szmarczak about 5 years ago

I suggesting emptying the cache, it's at the bottom of the options page

posted by fregante about 5 years ago

Yep, that worked!

posted by szmarczak about 5 years ago

Why has this been closed? Is it fixed already?

posted by szmarczak about 5 years ago

Fund this Issue

$0.00
Funded

Pull requests