File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
packages/cloudflare/src/api Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,10 @@ type Options = {
1818 /**
1919 * Whether the regional cache entry should be updated in the background or not when it experiences
2020 * a cache hit.
21+ *
22+ * Defaults to `false` for the `short-lived` mode, and `true` for the `long-lived` mode.
2123 */
22- shouldLazilyUpdateOnCacheHit : boolean ;
24+ shouldLazilyUpdateOnCacheHit ? : boolean ;
2325} ;
2426
2527class RegionalCache implements IncrementalCache {
@@ -32,6 +34,8 @@ class RegionalCache implements IncrementalCache {
3234 private opts : Options
3335 ) {
3436 this . name = this . store . name ;
37+
38+ this . opts . shouldLazilyUpdateOnCacheHit ??= this . opts . mode === "long-lived" ;
3539 }
3640
3741 async get < IsFetch extends boolean = false > (
@@ -155,6 +159,8 @@ class RegionalCache implements IncrementalCache {
155159 * - `long-lived`: Re-use a cache entry until it is revalidated.
156160 * @param opts.shouldLazilyUpdateOnCacheHit - Whether the regional cache entry should be updated in
157161 * the background or not when it experiences a cache hit.
162+ *
163+ * Defaults to `false` for the `short-lived` mode, and `true` for the `long-lived` mode.
158164 */
159165export function withRegionalCache ( cache : IncrementalCache , opts : Options ) {
160166 return new RegionalCache ( cache , opts ) ;
You can’t perform that action at this time.
0 commit comments