mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-14 02:10:59 +00:00
A while ago, caching was removed due to some issues (see #349). This is a new implementation with the following improvements: * Architecture: The new implementation is decoupled from the collector, which was a major issue in the last version. Now the collector has a single responsibility: collecting links. This also avoids race-conditions when running multiple collect_links instances, which probably was an issue before. * Performance: Uses DashMap under the hood, which was noticeably faster than Mutex<HashMap> in my tests. * Simplicity: The cache format is a CSV file with two columns: URI and status. I decided to create a new struct called CacheStatus for serialization, because trying to serialize the error kinds in Status turned out to be a bit of a nightmare and at this point I don't think it's worth the pain (and probably isn't idiomatic either). This is an optional feature. Caching only gets used if the `--cache` flag is set.
15 lines
358 B
Rust
15 lines
358 B
Rust
use std::time::SystemTime;
|
|
|
|
pub(crate) type Timestamp = u64;
|
|
|
|
/// Get the current UNIX timestamp
|
|
///
|
|
/// # Panics
|
|
///
|
|
/// Panics when the system clock is incorrectly configured
|
|
pub(crate) fn timestamp() -> Timestamp {
|
|
SystemTime::now()
|
|
.duration_since(SystemTime::UNIX_EPOCH)
|
|
.expect("SystemTime before UNIX EPOCH!")
|
|
.as_secs()
|
|
}
|