File tree Expand file tree Collapse file tree
packages/functional-tests/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,22 +29,31 @@ export class SmsClient {
2929 const expires = Date . now ( ) + timeout ;
3030
3131 while ( Date . now ( ) < expires ) {
32- const keys = await this . client . keys ( redisKeyPattern ) ;
32+ let cursor = '0' ;
3333 let newestKey : string | null = null ;
3434 let newestCreatedAt = - 1 ;
3535
36- for ( const key of keys ) {
37- const valueRaw = await this . client . get ( key ) ;
38- if ( ! valueRaw ) {
39- continue ;
40- }
41- const value = JSON . parse ( valueRaw ) ;
36+ do {
37+ const [ newCursor , keys ] = await this . client . scan (
38+ cursor ,
39+ 'MATCH' ,
40+ redisKeyPattern
41+ ) ;
42+ cursor = newCursor ;
43+
44+ for ( const key of keys ) {
45+ const valueRaw = await this . client . get ( key ) ;
46+ if ( ! valueRaw ) {
47+ continue ;
48+ }
49+ const value = JSON . parse ( valueRaw ) ;
4250
43- if ( ! newestKey || value . createdAt > newestCreatedAt ) {
44- newestKey = key ;
45- newestCreatedAt = value . createdAt ;
51+ if ( ! newestKey || value . createdAt > newestCreatedAt ) {
52+ newestKey = key ;
53+ newestCreatedAt = value . createdAt ;
54+ }
4655 }
47- }
56+ } while ( cursor !== '0' ) ;
4857
4958 // If no keys are found, wait and try again.
5059 if ( ! newestKey ) {
You can’t perform that action at this time.
0 commit comments