Skip to content

Commit 03ffc01

Browse files
committed
add comments and make the lazy boolean non-optional
1 parent a2b2667 commit 03ffc01

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,18 @@ const ONE_YEAR_IN_SECONDS = 31536000;
88
const ONE_MINUTE_IN_SECONDS = 60;
99

1010
type Options = {
11+
/**
12+
* The mode to use for the regional cache.
13+
*
14+
* - `short-lived`: Re-use a cache entry for up to a minute after it has been retrieved.
15+
* - `long-lived`: Re-use a cache entry until it is revalidated.
16+
*/
1117
mode: "short-lived" | "long-lived";
12-
shouldLazilyUpdateOnCacheHit?: boolean;
18+
/**
19+
* Whether the regional cache entry should be updated in the background or not when it experiences
20+
* a cache hit.
21+
*/
22+
shouldLazilyUpdateOnCacheHit: boolean;
1323
};
1424

1525
class RegionalCache implements IncrementalCache {
@@ -130,6 +140,19 @@ class RegionalCache implements IncrementalCache {
130140
}
131141
}
132142

143+
/**
144+
* A regional cache will wrap an incremental cache and provide faster cache lookups for an entry
145+
* when making requests within the region.
146+
*
147+
* The regional cache uses the Cache API.
148+
*
149+
* @param cache - Incremental cache instance.
150+
* @param opts.mode - The mode to use for the regional cache.
151+
* - `short-lived`: Re-use a cache entry for up to a minute after it has been retrieved.
152+
* - `long-lived`: Re-use a cache entry until it is revalidated.
153+
* @param opts.shouldLazilyUpdateOnCacheHit - Whether the regional cache entry should be updated in
154+
* the background or not when it experiences a cache hit.
155+
*/
133156
export function withRegionalCache(cache: IncrementalCache, opts: Options) {
134157
return new RegionalCache(cache, opts);
135158
}

0 commit comments

Comments
 (0)