File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,23 +46,15 @@ impl SuggestionStore {
4646 pub async fn list_all ( & self ) -> Result < HashMap < Uuid , MessageId > , Error > {
4747 let mut conn = self . conn . clone ( ) ;
4848 let pattern = format ! ( "{KEY_PREFIX}*" ) ;
49- let mut cursor = 0u64 ;
50- let mut keys: Vec < String > = Vec :: new ( ) ;
51- loop {
52- let ( next_cursor, batch) : ( u64 , Vec < String > ) = redis:: cmd ( "SCAN" )
53- . arg ( cursor)
54- . arg ( "MATCH" )
55- . arg ( & pattern)
56- . arg ( "COUNT" )
57- . arg ( 100 )
58- . query_async ( & mut conn)
59- . await ?;
60- keys. extend ( batch) ;
61- if next_cursor == 0 {
62- break ;
49+
50+ let keys: Vec < String > = {
51+ let mut iter: redis:: AsyncIter < ' _ , String > = conn. scan_match ( & pattern) . await ?;
52+ let mut collected = Vec :: new ( ) ;
53+ while let Some ( item) = iter. next_item ( ) . await {
54+ collected. push ( item?) ;
6355 }
64- cursor = next_cursor ;
65- }
56+ collected
57+ } ;
6658
6759 if keys. is_empty ( ) {
6860 return Ok ( HashMap :: new ( ) ) ;
You can’t perform that action at this time.
0 commit comments