Skip to content

Commit

Permalink
fix: cache impl
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed May 11, 2023
1 parent 759efe7 commit d937ab9
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions util/cache.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
let releaseCache = null

export default async function getLatestRelease() {
let data
if (releaseCache) {
data = releaseCache
} else {
console.log("fetching latest release")
data = await (await fetch('https://api.github.com/repos/GopeedLab/gopeed/releases/latest')).json()
releaseCache = data
// cache 1 hour
setTimeout(() => {
releaseCache = null
}, 1000 * 60 * 60)
}
return data
return await (await fetch('https://api.github.com/repos/GopeedLab/gopeed/releases/latest', { next: { revalidate: 300 } })).json()
}

0 comments on commit d937ab9

Please sign in to comment.