Spaces:
Running
Running
neon_arch
commited on
Commit
·
39af909
1
Parent(s):
4bb6c5e
:zap: perf: replace `Vec<T>` with `Box<T>` & initialize vectors with capacity by default (#603)
Browse files
src/cache/redis_cacher.rs
CHANGED
@@ -16,7 +16,7 @@ const REDIS_PIPELINE_SIZE: usize = 3;
|
|
16 |
/// connect to.
|
17 |
pub struct RedisCache {
|
18 |
/// It stores a pool of connections ready to be used.
|
19 |
-
connection_pool:
|
20 |
/// It stores the size of the connection pool (in other words the number of
|
21 |
/// connections that should be stored in the pool).
|
22 |
pool_size: u8,
|
@@ -58,13 +58,13 @@ impl RedisCache {
|
|
58 |
}));
|
59 |
}
|
60 |
|
61 |
-
let mut outputs = Vec::
|
62 |
for task in tasks {
|
63 |
outputs.push(task.await??);
|
64 |
}
|
65 |
|
66 |
let redis_cache = RedisCache {
|
67 |
-
connection_pool: outputs,
|
68 |
pool_size,
|
69 |
current_connection: Default::default(),
|
70 |
cache_ttl,
|
|
|
16 |
/// connect to.
|
17 |
pub struct RedisCache {
|
18 |
/// It stores a pool of connections ready to be used.
|
19 |
+
connection_pool: Box<[ConnectionManager]>,
|
20 |
/// It stores the size of the connection pool (in other words the number of
|
21 |
/// connections that should be stored in the pool).
|
22 |
pool_size: u8,
|
|
|
58 |
}));
|
59 |
}
|
60 |
|
61 |
+
let mut outputs = Vec::with_capacity(tasks.len());
|
62 |
for task in tasks {
|
63 |
outputs.push(task.await??);
|
64 |
}
|
65 |
|
66 |
let redis_cache = RedisCache {
|
67 |
+
connection_pool: outputs.into_boxed_slice(),
|
68 |
pool_size,
|
69 |
current_connection: Default::default(),
|
70 |
cache_ttl,
|