File size: 852 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
// @ts-check
const { requestIdStorage } = require('./als')
const defaultCacheHandler =
require('next/dist/server/lib/cache-handlers/default.external').default
/**
* @type {import('next/dist/server/lib/cache-handlers/types').CacheHandlerV2}
*/
const cacheHandler = {
async get(cacheKey) {
return defaultCacheHandler.get(cacheKey)
},
async set(cacheKey, pendingEntry) {
const requestId = requestIdStorage.getStore()
console.log('set cache', cacheKey, 'requestId:', requestId)
return defaultCacheHandler.set(cacheKey, pendingEntry)
},
async refreshTags() {
return defaultCacheHandler.refreshTags()
},
async getExpiration(...tags) {
return defaultCacheHandler.getExpiration(...tags)
},
async expireTags(...tags) {
return defaultCacheHandler.expireTags(...tags)
},
}
module.exports = cacheHandler
|