MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / clear_cache

Method clear_cache

graphlite/src/catalog/system_procedures.rs:901–969  ·  view source on GitHub ↗

CALL gql.clear_cache([cache_type]) YIELD status, cleared_caches

(&self, args: Vec<Value>)

Source from the content-addressed store, hash-verified

899
900 /// CALL gql.clear_cache([cache_type]) YIELD status, cleared_caches
901 fn clear_cache(&self, args: Vec<Value>) -> Result<QueryResult, ExecutionError> {
902 let cache_type = if !args.is_empty() {
903 match &args[0] {
904 Value::String(s) => Some(s.as_str()),
905 _ => None,
906 }
907 } else {
908 None
909 };
910
911 let mut cleared_caches = Vec::new();
912 let status = "success";
913
914 match cache_type {
915 Some("storage_cache") => {
916 let _ = self.storage.clear_cache();
917 cleared_caches.push("storage_cache");
918 }
919 Some("result_cache") | Some("plan_cache") | Some("subquery_cache") => {
920 if let Some(cache_manager) = &self.cache_manager {
921 cache_manager.clear_all();
922 cleared_caches.push("result_cache");
923 cleared_caches.push("plan_cache");
924 cleared_caches.push("subquery_cache");
925 } else {
926 return Err(ExecutionError::RuntimeError(
927 "Cache manager not available".to_string(),
928 ));
929 }
930 }
931 Some(unknown) => {
932 return Err(ExecutionError::RuntimeError(
933 format!("Unknown cache type: {}. Valid types: storage_cache, result_cache, plan_cache, subquery_cache", unknown)
934 ));
935 }
936 None => {
937 // Clear all caches
938 let _ = self.storage.clear_cache();
939 cleared_caches.push("storage_cache");
940
941 if let Some(cache_manager) = &self.cache_manager {
942 cache_manager.clear_all();
943 cleared_caches.push("result_cache");
944 cleared_caches.push("plan_cache");
945 cleared_caches.push("subquery_cache");
946 }
947 }
948 }
949
950 let columns = vec!["status".to_string(), "cleared_caches".to_string()];
951 let mut row_values = HashMap::new();
952 row_values.insert("status".to_string(), Value::String(status.to_string()));
953 row_values.insert(
954 "cleared_caches".to_string(),
955 Value::String(cleared_caches.join(", ")),
956 );
957
958 let rows = vec![Row::from_values(row_values)];

Callers 1

execute_procedureMethod · 0.45

Calls 4

clear_allMethod · 0.80
is_emptyMethod · 0.45
as_strMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected