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

Method save_graph

graphlite/src/storage/storage_manager.rs:209–260  ·  view source on GitHub ↗

Save a graph Updates cache, memory store (if available), and persistent storage

(&self, name: &str, graph: GraphCache)

Source from the content-addressed store, hash-verified

207 /// Save a graph
208 /// Updates cache, memory store (if available), and persistent storage
209 pub fn save_graph(&self, name: &str, graph: GraphCache) -> Result<(), StorageError> {
210 debug!("Saving graph '{}' to storage manager", name);
211
212 // Use the provided name consistently - don't try to normalize to short names
213 let cache_name = name.to_string();
214
215 // 1. Update cache
216 match self.cache.add_graph(cache_name.clone(), graph.clone()) {
217 Ok(_) => {
218 debug!("Successfully added graph '{}' to cache", cache_name);
219 }
220 Err(e) => {
221 error!("Failed to add graph '{}' to cache: {}", cache_name, e);
222 return Err(e);
223 }
224 }
225
226 // 2. Update memory store if available (TODO: Implement memory store save)
227 if let Some(_memory_store) = &self.memory_store {
228 debug!("Memory store save not yet implemented for graph '{}'", name);
229 }
230
231 // 3. Persist to disk storage if available
232 if let Some(persistent_store) = &self.persistent_store {
233 if let Some(driver) = &self.storage_driver {
234 debug!("Attempting to persist graph '{}' to disk", name);
235 persistent_store
236 .save_graph_by_path(driver.as_ref().as_ref(), &graph, name)
237 .map_err(|e| {
238 error!("Failed to persist graph '{}': {}", name, e);
239 StorageError::PersistenceError(format!(
240 "Failed to persist graph '{}': {}",
241 name, e
242 ))
243 })?;
244 debug!("Successfully persisted graph '{}' to disk", name);
245 } else {
246 debug!(
247 "No storage driver available, skipping disk persistence for '{}'",
248 name
249 );
250 }
251 } else {
252 debug!(
253 "No persistent store available, skipping disk persistence for '{}'",
254 name
255 );
256 }
257
258 debug!("Successfully saved graph '{}' to all storage tiers", name);
259 Ok(())
260 }
261
262 /// Get all graph names from cache and storage tiers
263 pub fn get_graph_names(&self) -> Result<Vec<String>, StorageError> {

Callers 8

add_graphMethod · 0.80
execute_ddl_operationMethod · 0.80
execute_ddl_operationMethod · 0.80
execute_ddl_operationMethod · 0.80
apply_undo_operationMethod · 0.80
execute_unified_flowMethod · 0.80
apply_undo_operationMethod · 0.80

Calls 3

cloneMethod · 0.80
save_graph_by_pathMethod · 0.80
add_graphMethod · 0.45

Tested by

no test coverage detected