@@ -49,20 +49,24 @@ export class RedisCacheProvider implements CacheProvider {
4949
5050 async invalidate ( options : CacheInvalidationOptions ) {
5151 if ( options . tags && options . tags . length > 0 ) {
52- await Promise . all ( options . tags . map ( tag => {
53- return new Promise ( ( resolve , reject ) => {
54- const stream = this . redis . sscanStream ( formatTagKey ( tag ) , {
55- count : 100 ,
52+ await Promise . all (
53+ options . tags . map ( tag => {
54+ return new Promise ( ( resolve , reject ) => {
55+ const stream = this . redis . sscanStream ( formatTagKey ( tag ) , {
56+ count : 100 ,
57+ } )
58+
59+ stream . on ( 'data' , async ( keys : string [ ] ) => {
60+ if ( keys . length > 1 ) {
61+ await this . redis . del ( ...keys )
62+ }
63+ } )
64+
65+ stream . on ( 'error' , reject )
66+ stream . on ( 'end' , resolve )
5667 } )
57-
58- stream . on ( 'data' , async ( keys : string [ ] ) => {
59- await this . redis . del ( ...keys )
60- } )
61-
62- stream . on ( 'error' , reject )
63- stream . on ( 'end' , resolve )
64- } )
65- } ) )
68+ } ) ,
69+ )
6670 }
6771 }
6872
@@ -73,8 +77,10 @@ export class RedisCacheProvider implements CacheProvider {
7377 match : 'zenstack:cache:*' ,
7478 } )
7579
76- stream . on ( 'data' , async keys => {
77- await this . redis . del ( ...keys )
80+ stream . on ( 'data' , async ( keys : string [ ] ) => {
81+ if ( keys . length > 1 ) {
82+ await this . redis . del ( ...keys )
83+ }
7884 } )
7985
8086 stream . on ( 'error' , reject )
0 commit comments