File tree Expand file tree Collapse file tree 3 files changed +29
-4
lines changed
overrides/incrementalCache Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @opennextjs/aws " : patch
3+ ---
4+
5+ add and expose new ` CachedFetchValue ` type
Original file line number Diff line number Diff line change @@ -50,9 +50,15 @@ const buildDynamoKey = (key: string) => {
5050 */
5151const multiTierCache : IncrementalCache = {
5252 name : "multi-tier-ddb-s3" ,
53- async get ( key , isFetch ) {
53+ async get < IsFetch extends boolean = false > ( key : string , isFetch ?: IsFetch ) {
5454 // First we check the local cache
55- const localCacheEntry = localCache . get ( key ) ;
55+ const localCacheEntry = localCache . get ( key ) as
56+ | {
57+ value : CacheValue < IsFetch > ;
58+ lastModified : number ;
59+ }
60+ | undefined ;
61+
5662 if ( localCacheEntry ) {
5763 if ( Date . now ( ) - localCacheEntry . lastModified < localCacheTTL ) {
5864 debug ( "Using local cache without checking ddb" ) ;
Original file line number Diff line number Diff line change @@ -54,15 +54,29 @@ export type CachedFile =
5454 meta ?: Meta ;
5555 } ;
5656
57- export type FetchCache = Object ;
57+ // type taken from: https://github.com/vercel/next.js/blob/9a1cd356/packages/next/src/server/response-cache/types.ts#L26-L38
58+ export type CachedFetchValue = {
59+ kind : "FETCH" ;
60+ data : {
61+ headers : { [ k : string ] : string } ;
62+ body : string ;
63+ url : string ;
64+ status ?: number ;
65+ // field used by older versions of Next.js (see: https://github.com/vercel/next.js/blob/fda1ecc/packages/next/src/server/response-cache/types.ts#L23)
66+ tags ?: string [ ] ;
67+ } ;
68+ // tags are only present with file-system-cache
69+ // fetch cache stores tags outside of cache entry
70+ tags ?: string [ ] ;
71+ } ;
5872
5973export type WithLastModified < T > = {
6074 lastModified ?: number ;
6175 value ?: T ;
6276} ;
6377
6478export type CacheValue < IsFetch extends boolean > = ( IsFetch extends true
65- ? FetchCache
79+ ? CachedFetchValue
6680 : CachedFile ) & { revalidate ?: number | false } ;
6781
6882export type IncrementalCache = {
You can’t perform that action at this time.
0 commit comments