Skip to content

Commit

Permalink
๐Ÿš€ memory cache #22
Browse files Browse the repository at this point in the history
  • Loading branch information
kenu committed May 7, 2024
1 parent d8cb751 commit 8e173ee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions web/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ async function goRenderPage(
const cache = {}
async function getAllVideos(uri, lang) {
// memory cache
if (cache[uri]) {
return cache[uri]
const key = uri + lang
if (cache[key]) {
return cache[key]
} else {
const list = await dao.findAllVideo(uri, lang)
cache[uri] = list
cache[key] = list
return list
}
}
Expand Down

0 comments on commit 8e173ee

Please sign in to comment.