db: share one now_f64() instead of four private copies

handlers, queue, send and link_cache each carried the same SystemTime
helper; a single crate::db::now_f64() removes the drift risk.
This commit is contained in:
2026-08-08 20:23:58 +08:00
parent 72130b9023
commit 99009aae9a
4 changed files with 13 additions and 22 deletions
+1 -7
View File
@@ -8,6 +8,7 @@
//! [`Config::link_cache_ttl`]; a stale entry is dropped lazily on read and
//! by the periodic prune in `main`.
use crate::db::now_f64;
use rusqlite::{Connection, params};
use serde::{Deserialize, Serialize};
use std::time::Duration;
@@ -163,13 +164,6 @@ impl LinkCache {
}
}
fn now_f64() -> f64 {
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_secs_f64())
.unwrap_or(0.0)
}
#[cfg(test)]
mod tests {
use super::*;