Skip to content

Commit

Permalink
fix(cache): remove workaround for Nitro < 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Nov 12, 2024
1 parent 0de01aa commit 5b65100
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/runtime/cache/driver.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ export default defineDriver((driverOpts) => {
...driver,
setItem(key, value, options) {
const event = nitroAsyncContext.tryUse()?.event
// TODO: remove this if once Nitro 2.10 is out with Nuxt version
// As this does not support properly swr (as expiration should not be used)
// Fallback to expires value ({"expires":1729118447040,...})
if (!options.ttl && typeof value === 'string') {
const expires = value.match(/^\{"expires":(\d+),/)?.[1]
if (expires) {
options.ttl = Math.round((Number(expires) - Date.now()) / 1000)
}
}
if (options.ttl) {
// Make sure to have a ttl of at least 60 seconds (Cloudflare KV limitation)
options.ttl = Math.max(options.ttl, 60)
Expand Down

0 comments on commit 5b65100

Please sign in to comment.