fix issues with recording statistical data (closes #6)

This commit is contained in:
Markus Brueckner 2026-01-31 08:35:52 +01:00
parent 1ae0533f2d
commit eb99095d3c
4 changed files with 5 additions and 4 deletions

2
Cargo.lock generated
View file

@ -530,7 +530,7 @@ dependencies = [
[[package]]
name = "enex-rcache"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"actix-web",
"actix-web-httpauth",

View file

@ -1,6 +1,6 @@
[package]
name = "enex-rcache"
version = "0.2.0"
version = "0.2.1"
edition = "2024"
[dependencies]

View file

@ -81,6 +81,7 @@ pub async fn put_cache_item(
},
);
shared.stats.successful_writes += 1;
shared.stats.cache_size += size;
update_boundary_items(&mut shared.stats, &shared.lru_cache);
});
debug!("Created cache item {}", hash.as_str());

View file

@ -20,13 +20,13 @@ pub fn update_boundary_items(stats: &mut Stats, entries: &WeightedLRUCache<Cache
for (_, value) in entries.iter() {
if stats
.oldest_entry_at
.is_none_or(|oldest_entry| oldest_entry < value.meta.create_at)
.is_none_or(|oldest_entry| oldest_entry > value.meta.create_at)
{
stats.oldest_entry_at = Some(value.meta.create_at);
}
if stats
.newest_entry_at
.is_none_or(|newest_entry| newest_entry > value.meta.create_at)
.is_none_or(|newest_entry| newest_entry < value.meta.create_at)
{
stats.newest_entry_at = Some(value.meta.create_at);
}