Cache hits are counted, not only their bytes
cache.memory_hit and cache.edge_hit went through record_bytes, which adds bytes to a meter without counting it, so every hit read as 0.
1 file+2−20/1 viewed
| 637 | 637 | async fn cached_at(&self, path: &str, forever: bool) -> Option<Vec<u8>> { | |
| 638 | 638 | let url = self.cache_url(path); | |
| 639 | 639 | if forever && let Some(bytes) = MEMORY.with(|memory| memory.borrow().get(&url)) { | |
| 640 | − | meters::record_bytes("cache.memory_hit", &self.key, 0, bytes.len() as u64); | |
| 640 | + | meters::record("cache.memory_hit", &self.key, 0, bytes.len() as u64); | |
| 641 | 641 | return Some(bytes); | |
| 642 | 642 | } | |
| 643 | 643 | let found = match worker::Cache::default().get(url.clone(), false).await { | |
| 646 | 646 | }; | |
| 647 | 647 | match &found { | |
| 648 | 648 | Some(bytes) => { | |
| 649 | − | meters::record_bytes("cache.edge_hit", &self.key, 0, bytes.len() as u64); | |
| 649 | + | meters::record("cache.edge_hit", &self.key, 0, bytes.len() as u64); | |
| 650 | 650 | if forever { | |
| 651 | 651 | MEMORY.with(|memory| memory.borrow_mut().put(url, bytes)); | |
| 652 | 652 | } |