@@ -5,9 +5,9 @@ use super::{Cacher, error::CacheError};
5
5
use crate :: models:: aggregation:: SearchResults ;
6
6
use crate :: parser:: Config ;
7
7
use error_stack:: Report ;
8
- use futures:: stream:: FuturesUnordered ;
9
8
use rayon:: iter:: { IntoParallelRefIterator , ParallelIterator } ;
10
9
use redis:: { AsyncCommands , Client , ExistenceCheck , SetExpiry , SetOptions , aio:: ConnectionManager } ;
10
+ use tokio:: task:: JoinSet ;
11
11
12
12
/// A constant holding the redis pipeline size.
13
13
const REDIS_PIPELINE_SIZE : usize = 3 ;
@@ -45,18 +45,16 @@ impl RedisCache {
45
45
cache_ttl : u16 ,
46
46
) -> Result < Self , Box < dyn std:: error:: Error > > {
47
47
let client = Client :: open ( redis_connection_url) ?;
48
- let tasks: FuturesUnordered < _ > = FuturesUnordered :: new ( ) ;
48
+ let mut tasks: JoinSet < _ > = JoinSet :: new ( ) ;
49
49
50
50
for _ in 0 ..pool_size {
51
51
let client_partially_cloned = client. clone ( ) ;
52
- tasks. push ( tokio:: spawn ( async move {
53
- client_partially_cloned. get_connection_manager ( ) . await
54
- } ) ) ;
52
+ tasks. spawn ( async move { client_partially_cloned. get_connection_manager ( ) . await } ) ;
55
53
}
56
54
57
55
let mut outputs = Vec :: with_capacity ( tasks. len ( ) ) ;
58
- for task in tasks {
59
- outputs. push ( task. await ??) ;
56
+ while let Some ( task) = tasks. join_next ( ) . await {
57
+ outputs. push ( task??) ;
60
58
}
61
59
62
60
let redis_cache = RedisCache {
0 commit comments