Add a new graph with the given name
(&self, name: String, graph: GraphCache)
| 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> { |