Skip to content

Commit a7f1588

Browse files
committed
feat: null cache handler
1 parent ffadbd7 commit a7f1588

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/handlers/cache.cts

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1+
import type { CacheHandler, CacheHandlerContext } from 'next/dist/server/lib/incremental-cache/index.js'
2+
13
/**
24
* Netlify Cache Handler
35
* (CJS format because Next.js doesn't support ESM yet)
46
*/
7+
export default class NetlifyCacheHandler implements CacheHandler {
8+
options: CacheHandlerContext
59

6-
export default class CacheHandler {
7-
options: any
8-
cache: Map<string, any>
9-
10-
constructor(options: any) {
10+
constructor(options: CacheHandlerContext) {
1111
this.options = options
12-
this.cache = new Map()
1312
}
1413

15-
// eslint-disable-next-line require-await
16-
async get(key: any) {
17-
return this.cache.get(key)
14+
// eslint-disable-next-line require-await, class-methods-use-this
15+
public async get(key: string, ctx: any) {
16+
console.log('NetlifyCacheHandler.get', key, JSON.stringify(ctx, null, 2))
17+
return null
18+
}
19+
20+
// eslint-disable-next-line require-await, class-methods-use-this
21+
public async set(key: string, data: any, ctx: any) {
22+
console.log('NetlifyCacheHandler.set', key, JSON.stringify(data, null, 2), JSON.stringify(ctx, null, 2))
1823
}
1924

20-
// eslint-disable-next-line require-await
21-
async set(key: any, data: any) {
22-
this.cache.set(key, {
23-
value: data,
24-
lastModified: Date.now(),
25-
})
25+
// eslint-disable-next-line class-methods-use-this, require-await
26+
public async revalidateTag(tag: string) {
27+
console.log('NetlifyCacheHandler.revalidateTag', tag)
2628
}
2729
}

0 commit comments

Comments
 (0)