Skip to content

Commit be76e04

Browse files
committed
change lazy update defaults
1 parent 4cdb308 commit be76e04

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/cloudflare/src/api/regional-cache.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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

2527
class 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
*/
159165
export function withRegionalCache(cache: IncrementalCache, opts: Options) {
160166
return new RegionalCache(cache, opts);

0 commit comments

Comments
 (0)