7818c2d736
Use dynamic import instead of require to load the incremental cache handled, so when using ESM it will still work. Updated the tests and merged them into new test suite, include 3 cases of custom cache definition: - CJS with `module.exports` - CJS with `exports.default` with ESM mark - ESM with `export default` Closes NEXT-1924 Fixes #58509
27 lines
562 B
JavaScript
27 lines
562 B
JavaScript
const cache = new Map()
|
|
|
|
class CacheHandler {
|
|
constructor(options) {
|
|
this.options = options
|
|
this.cache = {}
|
|
console.log('initialized custom cache-handler')
|
|
console.log('cache handler - esm default export')
|
|
}
|
|
|
|
async get(key) {
|
|
console.log('key', key)
|
|
console.log('cache-handler get', key)
|
|
return cache.get(key)
|
|
}
|
|
|
|
async set(key, data) {
|
|
console.log('set key', key)
|
|
console.log('cache-handler set', key)
|
|
cache.set(key, {
|
|
value: data,
|
|
lastModified: Date.now(),
|
|
})
|
|
}
|
|
}
|
|
|
|
export default CacheHandler
|