We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 09d0eae commit 5bd2a89Copy full SHA for 5bd2a89
apps/labrinth/src/database/redis.rs
@@ -65,11 +65,25 @@ impl RedisPool {
65
.build()
66
.expect("Redis connection failed");
67
68
- RedisPool {
+ let pool = RedisPool {
69
url,
70
pool,
71
meta_namespace: meta_namespace.unwrap_or("".to_string()),
72
- }
+ };
73
+
74
+ let interval = Duration::from_secs(30);
75
+ let max_age = Duration::from_secs(5 * 60); // 5 minutes
76
+ let pool_ref = pool.clone();
77
+ tokio::spawn(async move {
78
+ loop {
79
+ tokio::time::sleep(interval).await;
80
+ pool_ref
81
+ .pool
82
+ .retain(|_, metrics| metrics.last_used() < max_age);
83
+ }
84
+ });
85
86
+ pool
87
}
88
89
pub async fn register_and_set_metrics(
0 commit comments