@@ -104,28 +104,24 @@ class D1TagCache implements TagCache {
104104 try {
105105 const uniqueTags = new Set < string > ( ) ;
106106 const results = await db . batch (
107- tags . reduce < D1PreparedStatement [ ] > ( ( acc , { tag , path , revalidatedAt } ) => {
108- if ( revalidatedAt === 1 ) {
109- // new tag/path mapping from set
110- acc . push (
111- db
107+ tags
108+ . map ( ( { tag , path , revalidatedAt } ) => {
109+ if ( revalidatedAt === 1 ) {
110+ // new tag/path mapping from set
111+ return db
112112 . prepare ( `INSERT INTO ${ table . tags } (tag, path) VALUES (?, ?)` )
113- . bind ( this . getCacheKey ( tag ) , this . getCacheKey ( path ) )
114- ) ;
115- }
116-
117- if ( ! uniqueTags . has ( tag ) && revalidatedAt !== - 1 ) {
118- // tag was revalidated
119- uniqueTags . add ( tag ) ;
120- acc . push (
121- db
122- . prepare ( `INSERT INTO ${ table . revalidations } (tag, revalidatedAt) VALUES (?, ?)` )
123- . bind ( this . getCacheKey ( tag ) , revalidatedAt ?? Date . now ( ) )
124- ) ;
125- }
113+ . bind ( this . getCacheKey ( tag ) , this . getCacheKey ( path ) ) ;
114+ }
126115
127- return acc ;
128- } , [ ] )
116+ if ( ! uniqueTags . has ( tag ) && revalidatedAt !== - 1 ) {
117+ // tag was revalidated
118+ uniqueTags . add ( tag ) ;
119+ return db
120+ . prepare ( `INSERT INTO ${ table . revalidations } (tag, revalidatedAt) VALUES (?, ?)` )
121+ . bind ( this . getCacheKey ( tag ) , revalidatedAt ?? Date . now ( ) ) ;
122+ }
123+ } )
124+ . filter ( ( stmt ) => ! ! stmt )
129125 ) ;
130126
131127 const failedResults = results . filter ( ( res ) => ! res . success ) ;
0 commit comments