MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / readFileCached

Method readFileCached

src/resolution/index.ts:414–428  ·  view source on GitHub ↗

`readFile` through the LRU content cache (null = read failed, also cached).

(filePath: string)

Source from the content-addressed store, hash-verified

412
413 /** `readFile` through the LRU content cache (null = read failed, also cached). */
414 private readFileCached(filePath: string): string | null {
415 if (this.fileCache.has(filePath)) {
416 return this.fileCache.get(filePath)!;
417 }
418 const fullPath = path.join(this.projectRoot, filePath);
419 try {
420 const content = fs.readFileSync(fullPath, 'utf-8');
421 this.fileCache.set(filePath, content);
422 return content;
423 } catch (error) {
424 logDebug('Failed to read file for resolution', { filePath, error: String(error) });
425 this.fileCache.set(filePath, null);
426 return null;
427 }
428 }
429
430 /**
431 * Create the resolution context

Callers 1

createContextMethod · 0.95

Calls 5

logDebugFunction · 0.90
hasMethod · 0.80
getMethod · 0.65
joinMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected