File tree Expand file tree Collapse file tree 4 files changed +41
-30
lines changed
packages/nextjs-cache-handler Expand file tree Collapse file tree 4 files changed +41
-30
lines changed Original file line number Diff line number Diff line change 10
10
"type" : " git" ,
11
11
"url" : " git+https://github.com/fortedigital/nextjs-cache-handler.git"
12
12
},
13
- "version" : " 1.3.0-canary4 " ,
13
+ "version" : " 1.3.0-canary5 " ,
14
14
"type" : " module" ,
15
15
"license" : " MIT" ,
16
16
"description" : " Next.js cache handlers" ,
Original file line number Diff line number Diff line change 1
- import { Handler } from "@neshca/cache-handler" ;
1
+ import { CacheHandlerValue , Handler } from "@neshca/cache-handler" ;
2
2
import {
3
3
CachedAppPageValue ,
4
4
CachedRouteValue ,
5
5
ConvertedCachedAppPageValue ,
6
6
ConvertedCachedRouteValue ,
7
7
} from "./buffer-string-decorator.types" ;
8
+ import { IncrementalCacheValue } from "next/dist/server/response-cache" ;
9
+ import { Next15IncrementalCacheValue } from "./next15.types" ;
8
10
9
11
/*
10
12
* This cache handler converts buffers from cached route values to strings on save and back to buffers on read.
@@ -64,7 +66,12 @@ export default function bufferStringDecorator(handler: Handler): Handler {
64
66
} ,
65
67
66
68
async set ( key , data ) {
67
- const value = data . value ;
69
+ if ( ! data ?. value ) {
70
+ await handler . set ( key , data ) ;
71
+ return ;
72
+ }
73
+
74
+ const value = { ...data . value } ;
68
75
const kind = value ?. kind as string ;
69
76
70
77
if ( kind === "APP_ROUTE" ) {
@@ -100,7 +107,7 @@ export default function bufferStringDecorator(handler: Handler): Handler {
100
107
}
101
108
}
102
109
103
- await handler . set ( key , data ) ;
110
+ await handler . set ( key , { ... data , value } ) ;
104
111
} ,
105
112
106
113
async revalidateTag ( tag ) {
Original file line number Diff line number Diff line change 1
1
import { CacheHandler } from "@neshca/cache-handler" ;
2
- import { OutgoingHttpHeaders } from "http" ;
3
2
import {
4
- CachedRedirectValue ,
5
- CachedImageValue ,
6
3
CachedFetchValue ,
7
4
IncrementalCacheValue ,
8
5
} from "next/dist/server/response-cache" ;
9
-
10
- export interface CachedRouteValue {
11
- kind : "APP_ROUTE" ;
12
- body : Buffer ;
13
- status : number ;
14
- headers : OutgoingHttpHeaders ;
15
- }
16
-
17
- interface IncrementalCachedPageValue {
18
- kind : "APP_PAGE" ;
19
- html : string ;
20
- pageData : Object ;
21
- postponed : string | undefined ;
22
- headers : OutgoingHttpHeaders | undefined ;
23
- status : number | undefined ;
24
- }
25
-
26
- export type Next15IncrementalCacheValue =
27
- | CachedRedirectValue
28
- | IncrementalCachedPageValue
29
- | CachedImageValue
30
- | CachedFetchValue
31
- | CachedRouteValue ;
6
+ import { Next15IncrementalCacheValue } from "./next15.types" ;
32
7
33
8
/*
34
9
* Use this handler in Next 15.2.1 and higher after `revalidate` property had been removed from context object.
Original file line number Diff line number Diff line change
1
+ import {
2
+ CachedRedirectValue ,
3
+ CachedImageValue ,
4
+ CachedFetchValue ,
5
+ } from "next/dist/server/response-cache" ;
6
+ import { OutgoingHttpHeaders } from "http" ;
7
+
8
+ export interface CachedRouteValue {
9
+ kind : "APP_ROUTE" ;
10
+ body : Buffer ;
11
+ status : number ;
12
+ headers : OutgoingHttpHeaders ;
13
+ }
14
+
15
+ export interface IncrementalCachedPageValue {
16
+ kind : "APP_PAGE" ;
17
+ html : string ;
18
+ pageData : Object ;
19
+ postponed : string | undefined ;
20
+ headers : OutgoingHttpHeaders | undefined ;
21
+ status : number | undefined ;
22
+ }
23
+
24
+ export type Next15IncrementalCacheValue =
25
+ | CachedRedirectValue
26
+ | IncrementalCachedPageValue
27
+ | CachedImageValue
28
+ | CachedFetchValue
29
+ | CachedRouteValue ;
You can’t perform that action at this time.
0 commit comments