@@ -2,7 +2,8 @@ import { DurableObject } from "cloudflare:workers";
22
33import { internalPurgeCacheByTags } from "../overrides/internal" ;
44
5- const DEFAULT_BUFFER_TIME = 5 ; // seconds
5+ const DEFAULT_BUFFER_TIME_IN_SECONDS = 5 ;
6+ const MAX_NUMBER_OF_TAGS_PER_PURGE = 100 ;
67
78export class BucketCachePurge extends DurableObject < CloudflareEnv > {
89 bufferTimeInSeconds : number ;
@@ -11,7 +12,7 @@ export class BucketCachePurge extends DurableObject<CloudflareEnv> {
1112 super ( state , env ) ;
1213 this . bufferTimeInSeconds = env . NEXT_CACHE_DO_PURGE_BUFFER_TIME_IN_SECONDS
1314 ? parseInt ( env . NEXT_CACHE_DO_PURGE_BUFFER_TIME_IN_SECONDS )
14- : DEFAULT_BUFFER_TIME ; // Default buffer time
15+ : DEFAULT_BUFFER_TIME_IN_SECONDS ; // Default buffer time
1516
1617 // Initialize the sql table if it doesn't exist
1718 state . blockConcurrencyWhile ( async ( ) => {
@@ -45,7 +46,7 @@ export class BucketCachePurge extends DurableObject<CloudflareEnv> {
4546 let tags = this . ctx . storage . sql
4647 . exec < { tag : string } > (
4748 `
48- SELECT * FROM cache_purge LIMIT 100
49+ SELECT * FROM cache_purge LIMIT ${ MAX_NUMBER_OF_TAGS_PER_PURGE }
4950 `
5051 )
5152 . toArray ( ) ;
@@ -75,7 +76,7 @@ export class BucketCachePurge extends DurableObject<CloudflareEnv> {
7576 tags = this . ctx . storage . sql
7677 . exec < { tag : string } > (
7778 `
78- SELECT * FROM cache_purge LIMIT 100
79+ SELECT * FROM cache_purge LIMIT ${ MAX_NUMBER_OF_TAGS_PER_PURGE }
7980 `
8081 )
8182 . toArray ( ) ;
0 commit comments