Get a graph by name Checks cache first, then memory store, then persistent storage
(&self, name: &str)
| 151 | /// Get a graph by name |
| 152 | /// Checks cache first, then memory store, then persistent storage |
| 153 | pub fn get_graph(&self, name: &str) -> Result<Option<GraphCache>, StorageError> { |
| 154 | debug!("Getting graph '{}' from storage manager", name); |
| 155 | |
| 156 | // 1. Check local cache first |
| 157 | match self.cache.get_graph(name) { |
| 158 | Ok(Some(graph)) => { |
| 159 | debug!("Graph '{}' found in local cache", name); |
| 160 | return Ok(Some(graph)); |
| 161 | } |
| 162 | Ok(None) => { |
| 163 | debug!("Graph '{}' not found in local cache", name); |
| 164 | } |
| 165 | Err(e) => { |
| 166 | error!("Error checking cache for graph '{}': {}", name, e); |
| 167 | return Err(e); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | // No fallback logic - use exact names for consistency |
| 172 | |
| 173 | // 2. Check memory store if available |
| 174 | if let Some(_memory_store) = &self.memory_store { |
| 175 | debug!("Memory store not yet implemented for graph '{}'", name); |
| 176 | } |
| 177 | |
| 178 | // 3. Check persistent disk storage if available |
| 179 | debug!( |
| 180 | "Graph '{}' not in memory, checking persistent storage", |
| 181 | name |
| 182 | ); |
| 183 | |
| 184 | if let Some(persistent_store) = &self.persistent_store { |
| 185 | if let Some(driver) = &self.storage_driver { |
| 186 | match persistent_store.load_graph_by_path(driver.as_ref().as_ref(), name) { |
| 187 | Ok(graph) => { |
| 188 | debug!("Graph '{}' loaded from persistent storage", name); |
| 189 | |
| 190 | // Add to cache for future access |
| 191 | self.cache.add_graph(name.to_string(), graph.clone())?; |
| 192 | return Ok(Some(graph)); |
| 193 | } |
| 194 | Err(e) => { |
| 195 | debug!( |
| 196 | "Failed to load graph '{}' from persistent storage: {}", |
| 197 | name, e |
| 198 | ); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | Ok(None) |
| 205 | } |
| 206 | |
| 207 | /// Save a graph |
| 208 | /// Updates cache, memory store (if available), and persistent storage |
no test coverage detected