next.js/test/production/standalone-mode/required-server-files/cache-handler.js
cache-handler.js25 lines539 B
const cache = new Map()

module.exports = class CacheHandler {
  constructor() {
    console.log('initialized custom cache-handler')
  }

  async get(key, ctx) {
    console.log('cache-handler get', key, ctx)

    if (ctx.softTags?.some((tag) => tag.includes('?'))) {
      throw new Error(`invalid soft tag found should only be pathname`)
    }
    return cache.get(key)
  }

  async set(key, data, ctx) {
    console.log('cache-handler set', key, ctx)
    cache.set(key, {
      value: data,
      lastModified: Date.now(),
    })
  }
}
Quest for Codev2.0.0
/
SIGN IN