Format cache status as a PostgreSQL result set
()
| 37 | |
| 38 | /// Format cache status as a PostgreSQL result set |
| 39 | pub fn format_cache_status_as_table() -> (Vec<String>, DbRows) { |
| 40 | let status = get_cache_status(); |
| 41 | |
| 42 | let columns = vec![ |
| 43 | "metric".to_string(), |
| 44 | "value".to_string(), |
| 45 | ]; |
| 46 | |
| 47 | let rows = vec![ |
| 48 | vec![ |
| 49 | Some(b"total_queries".to_vec()), |
| 50 | Some(status.total_queries.to_string().into_bytes()), |
| 51 | ], |
| 52 | vec![ |
| 53 | Some(b"cache_hits".to_vec()), |
| 54 | Some(status.cache_hits.to_string().into_bytes()), |
| 55 | ], |
| 56 | vec![ |
| 57 | Some(b"cache_misses".to_vec()), |
| 58 | Some(status.cache_misses.to_string().into_bytes()), |
| 59 | ], |
| 60 | vec![ |
| 61 | Some(b"hit_rate_percent".to_vec()), |
| 62 | Some(format!("{:.1}", status.hit_rate).into_bytes()), |
| 63 | ], |
| 64 | vec![ |
| 65 | Some(b"evictions".to_vec()), |
| 66 | Some(status.evictions.to_string().into_bytes()), |
| 67 | ], |
| 68 | vec![ |
| 69 | Some(b"cache_size".to_vec()), |
| 70 | Some(status.cache_size.to_string().into_bytes()), |
| 71 | ], |
| 72 | vec![ |
| 73 | Some(b"cache_capacity".to_vec()), |
| 74 | Some(status.cache_capacity.to_string().into_bytes()), |
| 75 | ], |
| 76 | ]; |
| 77 | |
| 78 | (columns, rows) |
| 79 | } |
| 80 | |
| 81 | /// Log cache status to tracing |
| 82 | pub fn log_cache_status() { |
no test coverage detected