@@ -67,10 +67,11 @@ export class CacheTagService {
6767 tags : string [ ] ,
6868 options ?: SetKeyTagsOptions ,
6969 ) : Promise < void > {
70- const versions = await this . getTagVersions ( tags ) ;
70+ const uniqueTags = [ ...new Set ( tags ) ] ;
71+ const versions = await this . getTagVersions ( uniqueTags ) ;
7172 const snapshot : Record < string , number > = { } ;
72- for ( let i = 0 ; i < tags . length ; i ++ ) {
73- snapshot [ tags [ i ] ] = versions [ i ] ;
73+ for ( let i = 0 ; i < uniqueTags . length ; i ++ ) {
74+ snapshot [ uniqueTags [ i ] ] = versions [ i ] ;
7475 }
7576
7677 const entry : KeyTagEntry = { tags : snapshot } ;
@@ -131,16 +132,18 @@ export class CacheTagService {
131132 }
132133
133134 public async invalidateTags ( tags : string [ ] ) : Promise < string [ ] > {
134- if ( tags . length === 0 ) {
135+ const uniqueTags = [ ...new Set ( tags ) ] ;
136+ if ( uniqueTags . length === 0 ) {
135137 return tags ;
136138 }
137- const versions = await this . getTagVersions ( tags ) ;
138- await this . _store . setMany (
139- tags . map ( ( tag , i ) => ( {
140- key : this . tagKey ( tag ) ,
141- value : versions [ i ] + 1 ,
142- } ) ) ,
143- ) ;
139+ const versions = await this . getTagVersions ( uniqueTags ) ;
140+
141+ const kvPairs = [ ] ;
142+ for ( let i = 0 ; i < uniqueTags . length ; i ++ ) {
143+ kvPairs . push ( { key : this . tagKey ( uniqueTags [ i ] ) , value : versions [ i ] + 1 } ) ;
144+ }
145+
146+ await this . _store . setMany ( kvPairs ) ;
144147 return tags ;
145148 }
146149}
0 commit comments