Skip to content

Commit

Permalink
Set infinite TTL for redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
achavez committed May 23, 2024
1 parent 73e244e commit 7a7e5d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ middlewareRouter.use(async (req, res) => {

exports.middleware = middlewareRouter

exports.add = async (id, newModified, content) => {
exports.add = async (id, newModified, content, ttl) => {
if (!newModified) throw new Error(`Refusing to store ${id} without modified time.`)

const data = await cache.get(id)
Expand All @@ -49,7 +49,7 @@ exports.add = async (id, newModified, content) => {
// if there was previous data and it is not older than the new data, don't do anything
if (oldContent && modified && !isNewer(modified, newModified)) return // nothing to do if data is current
// store new data in the cache
return cache.set(id, {content, modified: newModified, id})
return cache.set(id, {content, modified: newModified, id}, {ttl: ttl})
}

// expose the purgeCache method externally so that list can call while building tree
Expand Down
2 changes: 1 addition & 1 deletion server/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async function setRedirects(oldDocsInfo, newDocsInfo) {
// if no lastPath, file is a new addition to the drive
if (currPath && lastPath && currPath !== lastPath) {
log.info(`Doc ${id} moved, REDIRECT ${lastPath}${currPath}`)
cache.add(lastPath, new Date(), {redirect: currPath})
cache.add(lastPath, new Date(), {redirect: currPath}, 0)
}
})
}
Expand Down

0 comments on commit 7a7e5d7

Please sign in to comment.