Skip to content

Commit

Permalink
Fix the problem of not using the 'tokio' runtime correctly when the c…
Browse files Browse the repository at this point in the history
…leanup() operation is performed.
  • Loading branch information
rmqtt committed Mar 9, 2024
1 parent f6c96b3 commit bb98b5f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/storage_redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ impl RedisStorageDB {

fn cleanup(self) -> Self {
let db = self.clone();
std::thread::spawn(move || loop {
std::thread::sleep(std::time::Duration::from_secs(30));
let mut async_conn = db.async_conn();
let db_zkey = db.make_len_sortedset_key();
futures::executor::block_on(async move {
tokio::spawn(async move {
loop {
tokio::time::sleep(std::time::Duration::from_secs(30)).await;
let mut async_conn = db.async_conn();
let db_zkey = db.make_len_sortedset_key();
if let Err(e) = async_conn
.zrembyscore::<'_, _, _, _, ()>(db_zkey.as_slice(), 0, timestamp_millis())
.await
{
log::error!("{:?}", e);
}
});
}
});
self
}
Expand Down

0 comments on commit bb98b5f

Please sign in to comment.