* Get a node by ID
(id: string)
| 1173 | * Get a node by ID |
| 1174 | */ |
| 1175 | getNodeById(id: string): Node | null { |
| 1176 | // Check cache first |
| 1177 | if (this.nodeCache.has(id)) { |
| 1178 | const cached = this.nodeCache.get(id)!; |
| 1179 | // Move to end to implement LRU (delete and re-add) |
| 1180 | this.nodeCache.delete(id); |
| 1181 | this.nodeCache.set(id, cached); |
| 1182 | return cached; |
| 1183 | } |
| 1184 | |
| 1185 | if (!this.stmts.getNodeById) { |
| 1186 | this.stmts.getNodeById = prepareNodeStatement(this.db, 'SELECT * FROM nodes WHERE id = ?'); |
| 1187 | } |
| 1188 | const node = this.stmts.getNodeById.get(id); |
| 1189 | if (!node) { |
| 1190 | return null; |
| 1191 | } |
| 1192 | |
| 1193 | this.cacheNode(node); |
| 1194 | return node; |
| 1195 | } |
| 1196 | |
| 1197 | /** |
| 1198 | * Batch lookup: fetch many nodes by ID in a single SQL round-trip. |