@opennextjs/cloudflare 1.16.0 → 1.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -76,17 +76,7 @@ declare class RegionalCache implements IncrementalCache {
|
|
|
76
76
|
* a request is made to another region that has an entry stored in its regional cache.
|
|
77
77
|
*
|
|
78
78
|
* @param cache Incremental cache instance.
|
|
79
|
-
* @param opts
|
|
80
|
-
* - `short-lived`: Re-use a cache entry for up to a minute after it has been retrieved.
|
|
81
|
-
* - `long-lived`: Re-use a fetch cache entry until it is revalidated (per-region),
|
|
82
|
-
* or an ISR/SSG entry for up to 30 minutes.
|
|
83
|
-
* @param opts.shouldLazilyUpdateOnCacheHit Whether the regional cache entry should be updated in
|
|
84
|
-
* the background or not when it experiences a cache hit.
|
|
85
|
-
* @param opts.defaultLongLivedTtlSec The default age to use for long-lived cache entries.
|
|
86
|
-
* When no revalidate is provided, the default age will be used.
|
|
87
|
-
* @default `THIRTY_MINUTES_IN_SECONDS`
|
|
88
|
-
*
|
|
89
|
-
* @default `false` for the `short-lived` mode, and `true` for the `long-lived` mode.
|
|
79
|
+
* @param opts Options for the regional cache.
|
|
90
80
|
*/
|
|
91
81
|
export declare function withRegionalCache(cache: IncrementalCache, opts: Options): RegionalCache;
|
|
92
82
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { error } from "@opennextjs/aws/adapters/logger.js";
|
|
2
2
|
import { getCloudflareContext } from "../../cloudflare-context.js";
|
|
3
3
|
import { debugCache, FALLBACK_BUILD_ID, isPurgeCacheEnabled } from "../internal.js";
|
|
4
|
-
import { NAME as KV_CACHE_NAME } from "./kv-incremental-cache.js";
|
|
5
4
|
const ONE_MINUTE_IN_SECONDS = 60;
|
|
6
5
|
const THIRTY_MINUTES_IN_SECONDS = ONE_MINUTE_IN_SECONDS * 30;
|
|
7
6
|
/**
|
|
@@ -24,18 +23,15 @@ class RegionalCache {
|
|
|
24
23
|
constructor(store, opts) {
|
|
25
24
|
this.store = store;
|
|
26
25
|
this.opts = opts;
|
|
27
|
-
if (this.store.name === KV_CACHE_NAME) {
|
|
28
|
-
throw new Error("The KV incremental cache does not need a regional cache.");
|
|
29
|
-
}
|
|
30
26
|
this.name = this.store.name;
|
|
27
|
+
// `shouldLazilyUpdateOnCacheHit` is not needed when cache purge is enabled.
|
|
31
28
|
this.opts.shouldLazilyUpdateOnCacheHit ??= this.opts.mode === "long-lived" && !isPurgeCacheEnabled();
|
|
32
29
|
}
|
|
33
30
|
get #bypassTagCacheOnCacheHit() {
|
|
34
31
|
if (this.opts.bypassTagCacheOnCacheHit !== undefined) {
|
|
35
|
-
// If the bypassTagCacheOnCacheHit option is set we return that one
|
|
36
32
|
return this.opts.bypassTagCacheOnCacheHit;
|
|
37
33
|
}
|
|
38
|
-
//
|
|
34
|
+
// When `bypassTagCacheOnCacheHit` is not set, we default to whether the automatic cache purging is enabled or not
|
|
39
35
|
return isPurgeCacheEnabled();
|
|
40
36
|
}
|
|
41
37
|
async get(key, cacheType) {
|
|
@@ -148,17 +144,7 @@ class RegionalCache {
|
|
|
148
144
|
* a request is made to another region that has an entry stored in its regional cache.
|
|
149
145
|
*
|
|
150
146
|
* @param cache Incremental cache instance.
|
|
151
|
-
* @param opts
|
|
152
|
-
* - `short-lived`: Re-use a cache entry for up to a minute after it has been retrieved.
|
|
153
|
-
* - `long-lived`: Re-use a fetch cache entry until it is revalidated (per-region),
|
|
154
|
-
* or an ISR/SSG entry for up to 30 minutes.
|
|
155
|
-
* @param opts.shouldLazilyUpdateOnCacheHit Whether the regional cache entry should be updated in
|
|
156
|
-
* the background or not when it experiences a cache hit.
|
|
157
|
-
* @param opts.defaultLongLivedTtlSec The default age to use for long-lived cache entries.
|
|
158
|
-
* When no revalidate is provided, the default age will be used.
|
|
159
|
-
* @default `THIRTY_MINUTES_IN_SECONDS`
|
|
160
|
-
*
|
|
161
|
-
* @default `false` for the `short-lived` mode, and `true` for the `long-lived` mode.
|
|
147
|
+
* @param opts Options for the regional cache.
|
|
162
148
|
*/
|
|
163
149
|
export function withRegionalCache(cache, opts) {
|
|
164
150
|
return new RegionalCache(cache, opts);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opennextjs/cloudflare",
|
|
3
3
|
"description": "Cloudflare builder for next apps",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"opennextjs-cloudflare": "dist/cli/index.js"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ast-grep/napi": "0.40.0",
|
|
46
46
|
"@dotenvx/dotenvx": "1.31.0",
|
|
47
|
-
"@opennextjs/aws": "3.9.
|
|
47
|
+
"@opennextjs/aws": "3.9.14",
|
|
48
48
|
"cloudflare": "^4.4.1",
|
|
49
49
|
"enquirer": "^2.4.1",
|
|
50
50
|
"glob": "^12.0.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"build": "pnpm clean && tsc",
|
|
84
84
|
"build:watch": "tsc -w",
|
|
85
85
|
"lint:check": "eslint",
|
|
86
|
-
"lint:fix": "eslint --fix",
|
|
86
|
+
"lint:fix": "eslint --cache --fix",
|
|
87
87
|
"ts:check": "tsc --noEmit",
|
|
88
88
|
"test": "vitest --run",
|
|
89
89
|
"test:watch": "vitest"
|