* Add a node to the cache, evicting oldest if needed
(node: Node)
| 897 | * Add a node to the cache, evicting oldest if needed |
| 898 | */ |
| 899 | private cacheNode(node: Node): void { |
| 900 | if (this.nodeCache.size >= this.maxCacheSize) { |
| 901 | // Evict oldest (first) entry |
| 902 | const firstKey = this.nodeCache.keys().next().value; |
| 903 | if (firstKey) { |
| 904 | this.nodeCache.delete(firstKey); |
| 905 | } |
| 906 | } |
| 907 | this.nodeCache.set(node.id, node); |
| 908 | } |
| 909 | |
| 910 | /** |
| 911 | * Clear the node cache |
no test coverage detected