@@ -197,23 +197,23 @@ class ShardedDOTagCache implements NextModeTagCache {
197197 // If we have regional replication enabled, we need to further duplicate the shards in all the regions
198198 const regionalReplicasInAllRegions = generateAllReplicas
199199 ? regionalReplicas . flatMap ( ( { doId, tag } ) => {
200- return AVAILABLE_REGIONS . map ( ( region ) => {
201- return {
202- doId : new DOId ( {
203- baseShardId : doId . options . baseShardId ,
204- numberOfReplicas : numReplicas ,
205- shardType,
206- replicaId : doId . replicaId ,
207- region,
208- } ) ,
209- tag,
210- } ;
211- } ) ;
212- } )
200+ return AVAILABLE_REGIONS . map ( ( region ) => {
201+ return {
202+ doId : new DOId ( {
203+ baseShardId : doId . options . baseShardId ,
204+ numberOfReplicas : numReplicas ,
205+ shardType,
206+ replicaId : doId . replicaId ,
207+ region,
208+ } ) ,
209+ tag,
210+ } ;
211+ } ) ;
212+ } )
213213 : regionalReplicas . map ( ( { doId, tag } ) => {
214- doId . region = this . getClosestRegion ( ) ;
215- return { doId, tag } ;
216- } ) ;
214+ doId . region = this . getClosestRegion ( ) ;
215+ return { doId, tag } ;
216+ } ) ;
217217 return regionalReplicasInAllRegions ;
218218 }
219219
@@ -286,9 +286,9 @@ class ShardedDOTagCache implements NextModeTagCache {
286286 return ! db || isDisabled
287287 ? { isDisabled : true as const }
288288 : {
289- isDisabled : false as const ,
290- db,
291- } ;
289+ isDisabled : false as const ,
290+ db,
291+ } ;
292292 }
293293
294294 async getLastRevalidated ( tags : string [ ] ) : Promise < number > {
@@ -311,15 +311,10 @@ class ShardedDOTagCache implements NextModeTagCache {
311311 const stub = this . getDurableObjectStub ( doId ) ;
312312 const lastRevalidated = await stub . getLastRevalidated ( filteredTags ) ;
313313
314- const result = Math . max (
315- ...cachedValue . map ( ( item ) => item . time ) ,
316- lastRevalidated
317- ) ;
314+ const result = Math . max ( ...cachedValue . map ( ( item ) => item . time ) , lastRevalidated ) ;
318315
319316 // We then need to populate the regional cache with the missing tags
320- getCloudflareContext ( ) . ctx . waitUntil (
321- this . putToRegionalCache ( { doId, tags } , stub )
322- ) ;
317+ getCloudflareContext ( ) . ctx . waitUntil ( this . putToRegionalCache ( { doId, tags } , stub ) ) ;
323318
324319 return result ;
325320 } )
@@ -402,9 +397,7 @@ class ShardedDOTagCache implements NextModeTagCache {
402397 await stub . writeTags ( tags , lastModified ) ;
403398 // Depending on the shards and the tags, deleting from the regional cache will not work for every tag
404399 // We also need to delete both cache
405- await Promise . all ( [
406- this . deleteRegionalCache ( { doId, tags } ) ,
407- ] ) ;
400+ await Promise . all ( [ this . deleteRegionalCache ( { doId, tags } ) ] ) ;
408401 } catch ( e ) {
409402 error ( "Error while writing tags" , e ) ;
410403 if ( retryNumber >= this . maxWriteRetries ) {
@@ -433,9 +426,6 @@ class ShardedDOTagCache implements NextModeTagCache {
433426 return `http://local.cache/shard/${ doId . shardId } ?tag=${ encodeURIComponent ( tag ) } ` ;
434427 }
435428
436-
437-
438-
439429 /**
440430 * Get the last revalidation time for the tags from the regional cache
441431 * If the cache is not enabled, it will return an empty array
@@ -477,16 +467,20 @@ class ShardedDOTagCache implements NextModeTagCache {
477467 if ( lastRevalidated === undefined ) return ; // Should we store something in the cache if the tag is not found ?
478468 const cacheKey = this . getCacheUrlKey ( optsKey . doId , tag ) ;
479469 debugCache ( "Putting to regional cache" , { cacheKey, lastRevalidated } ) ;
480- await cache . put ( cacheKey , new Response ( lastRevalidated . toString ( ) , {
481- status : 200 , headers : {
482- "cache-control" : `max-age=${ this . opts . regionalCacheTtlSec ?? 5 } ` ,
483- ...( tags . length > 0
484- ? {
485- "cache-tag" : tags . join ( "," ) ,
486- }
487- : { } )
488- }
489- } ) ) ;
470+ await cache . put (
471+ cacheKey ,
472+ new Response ( lastRevalidated . toString ( ) , {
473+ status : 200 ,
474+ headers : {
475+ "cache-control" : `max-age=${ this . opts . regionalCacheTtlSec ?? 5 } ` ,
476+ ...( tags . length > 0
477+ ? {
478+ "cache-tag" : tags . join ( "," ) ,
479+ }
480+ : { } ) ,
481+ } ,
482+ } )
483+ ) ;
490484 } )
491485 ) ;
492486 }
0 commit comments