File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,16 +29,17 @@ export async function checkAndUpdateRateLimit(opts: CheckAndUpdateRateLimitOptio
2929
3030 const [ res , ttl ] = ( await mainMulti . exec ( ) ) as [ RateLimitCache , number ] ;
3131
32- if ( ttl === - 1 ) {
33- console . error ( `Rate limit key has no TTL: key=${ key } res=${ JSON . stringify ( res ) } ` ) ;
34- return false ;
35- }
32+ // if (ttl === -1) {
33+ // console.error(`Rate limit key has no TTL: key=${key} res=${JSON.stringify(res)}`);
34+ // return false;
35+ // }
3636
3737 if ( ! res || Object . keys ( res ) . length === 0 ) {
3838 const multi = redisClient . multi ( ) ;
39- multi . hSetNX ( key , 'requests' , '1' ) ;
40-
41- multi . pExpire ( key , opts . perMS , 'NX' ) ;
39+ multi . hSet ( key , {
40+ requests : 1 ,
41+ } ) ;
42+ multi . pExpire ( key , opts . perMS ) ;
4243 await multi . exec ( ) ;
4344 return false as const ;
4445 }
@@ -69,7 +70,7 @@ export async function checkAndUpdateRateLimit(opts: CheckAndUpdateRateLimitOptio
6970 multi . hSet ( key , {
7071 status : RateLimitStatus . REACHED ,
7172 } ) ;
72- multi . pExpire ( key , opts . restrictMS , 'NX' ) ;
73+ multi . pExpire ( key , opts . restrictMS ) ;
7374 await multi . exec ( ) ;
7475 return ttl ;
7576 }
You can’t perform that action at this time.
0 commit comments