CALL gql.cache_stats() YIELD cache_type, entries, hit_rate, memory_bytes
(&self, _args: Vec<Value>)
| 785 | |
| 786 | /// CALL gql.cache_stats() YIELD cache_type, entries, hit_rate, memory_bytes |
| 787 | fn cache_stats(&self, _args: Vec<Value>) -> Result<QueryResult, ExecutionError> { |
| 788 | let mut rows = Vec::new(); |
| 789 | let columns = vec![ |
| 790 | "cache_type".to_string(), |
| 791 | "entries".to_string(), |
| 792 | "hit_rate".to_string(), |
| 793 | "memory_bytes".to_string(), |
| 794 | ]; |
| 795 | |
| 796 | // Check if cache manager is available |
| 797 | if let Some(cache_manager) = &self.cache_manager { |
| 798 | let stats = cache_manager.get_stats(); |
| 799 | |
| 800 | // Storage cache (from StorageManager) |
| 801 | let storage_stats = self.storage.get_cache_stats(); |
| 802 | let mut row_values = HashMap::new(); |
| 803 | row_values.insert( |
| 804 | "cache_type".to_string(), |
| 805 | Value::String("storage_cache".to_string()), |
| 806 | ); |
| 807 | row_values.insert("entries".to_string(), Value::Number(storage_stats.0 as f64)); |
| 808 | row_values.insert("hit_rate".to_string(), Value::String("N/A".to_string())); |
| 809 | row_values.insert( |
| 810 | "memory_bytes".to_string(), |
| 811 | Value::Number(storage_stats.1 as f64), |
| 812 | ); |
| 813 | rows.push(Row::from_values(row_values)); |
| 814 | |
| 815 | // Result cache |
| 816 | let result_stats = &stats.result_cache; |
| 817 | let mut row_values = HashMap::new(); |
| 818 | row_values.insert( |
| 819 | "cache_type".to_string(), |
| 820 | Value::String("result_cache".to_string()), |
| 821 | ); |
| 822 | row_values.insert("entries".to_string(), Value::Number(0.0)); // ResultCacheStats doesn't track entries directly |
| 823 | row_values.insert( |
| 824 | "hit_rate".to_string(), |
| 825 | Value::Number(result_stats.hit_rate()), |
| 826 | ); |
| 827 | row_values.insert( |
| 828 | "memory_bytes".to_string(), |
| 829 | Value::Number(result_stats.memory_savings_bytes as f64), |
| 830 | ); |
| 831 | rows.push(Row::from_values(row_values)); |
| 832 | |
| 833 | // Plan cache |
| 834 | let plan_stats = &stats.plan_cache; |
| 835 | let mut row_values = HashMap::new(); |
| 836 | row_values.insert( |
| 837 | "cache_type".to_string(), |
| 838 | Value::String("plan_cache".to_string()), |
| 839 | ); |
| 840 | row_values.insert( |
| 841 | "entries".to_string(), |
| 842 | Value::Number(plan_stats.current_entries as f64), |
| 843 | ); |
| 844 | row_values.insert("hit_rate".to_string(), Value::Number(plan_stats.hit_rate())); |
no test coverage detected