@@ -8,8 +8,18 @@ const ONE_YEAR_IN_SECONDS = 31536000;
88const ONE_MINUTE_IN_SECONDS = 60 ;
99
1010type 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
1525class 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+ */
133156export function withRegionalCache ( cache : IncrementalCache , opts : Options ) {
134157 return new RegionalCache ( cache , opts ) ;
135158}
0 commit comments