|
| 1 | +import type { CacheHandler, CacheHandlerContext } from 'next/dist/server/lib/incremental-cache/index.js' |
| 2 | + |
1 | 3 | /** |
2 | 4 | * Netlify Cache Handler |
3 | 5 | * (CJS format because Next.js doesn't support ESM yet) |
4 | 6 | */ |
| 7 | +export default class NetlifyCacheHandler implements CacheHandler { |
| 8 | + options: CacheHandlerContext |
5 | 9 |
|
6 | | -export default class CacheHandler { |
7 | | - options: any |
8 | | - cache: Map<string, any> |
9 | | - |
10 | | - constructor(options: any) { |
| 10 | + constructor(options: CacheHandlerContext) { |
11 | 11 | this.options = options |
12 | | - this.cache = new Map() |
13 | 12 | } |
14 | 13 |
|
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)) |
18 | 23 | } |
19 | 24 |
|
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) |
26 | 28 | } |
27 | 29 | } |
0 commit comments