More efficient clean_up of MessageCache
This commit is contained in:
parent
fc726dbcf5
commit
7b34096940
@ -50,24 +50,9 @@ impl MessageCache {
|
|||||||
let mut store = cache.store.lock().unwrap();
|
let mut store = cache.store.lock().unwrap();
|
||||||
|
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let to_rm: Vec<String> = store
|
store.retain(|_, &mut entrytime| {
|
||||||
.iter()
|
now.duration_since(entrytime) <= MESSAGECACHEDURATION
|
||||||
.filter_map(|(entry, entrytime)| {
|
});
|
||||||
if let Some(duration) = now.checked_duration_since(*entrytime) {
|
|
||||||
if duration > MESSAGECACHEDURATION {
|
|
||||||
Some(entry.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
for key in to_rm {
|
|
||||||
store.remove(&key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user