v0.34.0_1
This commit is contained in:
1 parent
9cfc4588cc
commit
f20c8da718
25 files changed
+694
-117
No files matched your search
Vendored
+11
-32
@@ -176,8 +176,7 @@ impl Cache {
|
||||
if let Some(revision) = revision {
|
||||
store.revision = revision;
|
||||
self.revision.store(revision, Ordering::Relaxed);
|
||||
store.domains.clear();
|
||||
store.domain_count = 0;
|
||||
self.domain_stats.clear();
|
||||
}
|
||||
drop(store);
|
||||
self.cancel_all_fill_flights();
|
||||
@@ -264,44 +263,24 @@ impl Cache {
|
||||
view
|
||||
}
|
||||
pub fn record(&self, scope: &str, domain: &str, outcome: &str, reason: &'static str) {
|
||||
let mut store = self.store.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if let Some(c) = store.domain(scope, domain) {
|
||||
match outcome {
|
||||
"HIT" => c.hits += 1,
|
||||
"MISS" => c.misses += 1,
|
||||
_ => c.bypasses += 1,
|
||||
}
|
||||
if let Some(count) = c.reasons.get_mut(reason) {
|
||||
*count = count.saturating_add(1);
|
||||
} else {
|
||||
c.reasons.insert(reason.to_owned(), 1);
|
||||
}
|
||||
}
|
||||
self.domain_stats.record(scope, domain, outcome, reason);
|
||||
}
|
||||
pub fn record_reason(&self, scope: &str, domain: &str, reason: &'static str) {
|
||||
let mut store = self.store.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if let Some(c) = store.domain(scope, domain) {
|
||||
if let Some(count) = c.reasons.get_mut(reason) {
|
||||
*count = count.saturating_add(1);
|
||||
} else {
|
||||
c.reasons.insert(reason.to_owned(), 1);
|
||||
}
|
||||
}
|
||||
self.domain_stats.record_reason(scope, domain, reason);
|
||||
}
|
||||
pub fn dashboard(&self, scope: Option<&str>, offset: usize, limit: usize) -> Dashboard {
|
||||
let mut store = self.store.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let revision = store.revision;
|
||||
let mut groups: BTreeMap<(String, String), DomainView> = store
|
||||
.domains
|
||||
.iter()
|
||||
.filter(|(vhost, _)| scope.is_none_or(|s| s == vhost.as_str()))
|
||||
.flat_map(|(vhost, domains)| domains.iter().map(move |(domain, counters)| (vhost, domain, counters)))
|
||||
.map(|(vhost, domain, counters)| {
|
||||
let mut groups: BTreeMap<(String, String), DomainView> = self
|
||||
.domain_stats
|
||||
.snapshot(scope)
|
||||
.into_iter()
|
||||
.map(|((vhost, domain), counters)| {
|
||||
(
|
||||
(vhost.clone(), domain.clone()),
|
||||
DomainView {
|
||||
vhost: vhost.clone(),
|
||||
domain: domain.clone(),
|
||||
vhost,
|
||||
domain,
|
||||
entries: 0,
|
||||
logical_bytes: 0,
|
||||
resident_bytes: 0,
|
||||
@@ -313,7 +292,7 @@ impl Cache {
|
||||
} else {
|
||||
0.0
|
||||
},
|
||||
counters: counters.clone(),
|
||||
counters,
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user