loadCacheFromDisk() — mcp Function Reference
Architecture documentation for the loadCacheFromDisk() function in graph-cache.ts from the mcp codebase.
Entity Profile
Dependency Diagram
graph TD 4def3ca5_c0bf_fbae_1c00_3a7385fe0264["loadCacheFromDisk()"] a9363f44_0cfc_87dc_a76a_4eeb9d75c684["start()"] a9363f44_0cfc_87dc_a76a_4eeb9d75c684 -->|calls| 4def3ca5_c0bf_fbae_1c00_3a7385fe0264 69fc7a46_28f6_6b72_2725_66c381e53322["debug()"] 4def3ca5_c0bf_fbae_1c00_3a7385fe0264 -->|calls| 69fc7a46_28f6_6b72_2725_66c381e53322 e5352615_c5fb_64a2_cc5c_a248578cbc8a["warn()"] 4def3ca5_c0bf_fbae_1c00_3a7385fe0264 -->|calls| e5352615_c5fb_64a2_cc5c_a248578cbc8a 11d5249b_82de_e1fb_e621_e95ae1a093c5["buildIndexes()"] 4def3ca5_c0bf_fbae_1c00_3a7385fe0264 -->|calls| 11d5249b_82de_e1fb_e621_e95ae1a093c5 6407330b_8aa1_cc04_569a_747f6b1debfd["set()"] 4def3ca5_c0bf_fbae_1c00_3a7385fe0264 -->|calls| 6407330b_8aa1_cc04_569a_747f6b1debfd 90af3150_ce81_c645_faa7_5b8b9bcf5ecc["has()"] 4def3ca5_c0bf_fbae_1c00_3a7385fe0264 -->|calls| 90af3150_ce81_c645_faa7_5b8b9bcf5ecc style 4def3ca5_c0bf_fbae_1c00_3a7385fe0264 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/cache/graph-cache.ts lines 398–458
export async function loadCacheFromDisk(
cacheDir: string,
cache: GraphCache
): Promise<Map<string, IndexedGraph>> {
const repoMap = new Map<string, IndexedGraph>();
let entries: string[];
try {
entries = await fs.readdir(cacheDir);
} catch (error: any) {
if (error.code === 'ENOENT') {
logger.debug('Cache directory does not exist:', cacheDir);
return repoMap;
}
throw error;
}
const jsonFiles = entries.filter(e => e.endsWith('.json'));
logger.debug(`Found ${jsonFiles.length} cache files in ${cacheDir}`);
for (const file of jsonFiles) {
try {
const filePath = join(cacheDir, file);
const content = await fs.readFile(filePath, 'utf-8');
const payload = JSON.parse(content);
if (!payload.raw || !payload.repoName) {
logger.warn(`Skipping invalid cache file: ${file}`);
continue;
}
const repoName = payload.repoName as string;
const cacheKey = `precache:${repoName}`;
const graph = buildIndexes(payload.raw, cacheKey);
cache.set(cacheKey, graph);
repoMap.set(repoName.toLowerCase(), graph);
// Index by commit hash for exact matching (e.g. "commit:abc1234")
const commitHash = payload.commitHash as string | null;
if (commitHash) {
repoMap.set(`commit:${commitHash}`, graph);
}
// Also store common variants of the repo name for matching
// e.g. "django" for "django__django", "astropy" for "astropy__astropy"
const parts = repoName.toLowerCase().split(/[_\-\/]/);
for (const part of parts) {
if (part && part.length > 2 && !repoMap.has(part)) {
repoMap.set(part, graph);
}
}
logger.debug(`Loaded pre-computed graph for ${repoName} (commit: ${commitHash || 'unknown'}): ${graph.summary.nodeCount} nodes`);
} catch (error: any) {
logger.warn(`Failed to load cache file ${file}: ${error.message}`);
}
}
return repoMap;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does loadCacheFromDisk() do?
loadCacheFromDisk() is a function in the mcp codebase.
What does loadCacheFromDisk() call?
loadCacheFromDisk() calls 5 function(s): buildIndexes, debug, has, set, warn.
What calls loadCacheFromDisk()?
loadCacheFromDisk() is called by 1 function(s): start.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free