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

Method add_graph

graphlite/src/storage/multi_graph.rs:39–54  ·  view source on GitHub ↗

Add a new graph with the given name

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

Source from the content-addressed store, hash-verified

37
38 /// Add a new graph with the given name
39 pub fn add_graph(&self, name: String, graph: GraphCache) -> Result<(), StorageError> {
40 debug!("Adding graph: '{}' (key length: {})", name, name.len());
41
42 let mut graphs = self
43 .graphs
44 .write()
45 .map_err(|e| StorageError::LockError(format!("Failed to acquire write lock: {}", e)))?;
46
47 if graphs.contains_key(&name) {
48 debug!("Graph {} already exists in memory, replacing", name);
49 }
50
51 graphs.insert(name.clone(), graph);
52 debug!("Successfully added graph '{}' to memory", name);
53 Ok(())
54 }
55
56 /// Get a graph by name (read-only access)
57 pub fn get_graph(&self, name: &str) -> Result<Option<GraphCache>, StorageError> {

Callers 4

get_graphMethod · 0.45
save_graphMethod · 0.45
get_graph_mutMethod · 0.45

Calls 3

cloneMethod · 0.80
contains_keyMethod · 0.45
insertMethod · 0.45

Tested by 1