MCPcopy Create free account
hub / github.com/MicrosoftDocs/mcp / readCacheFile

Method readCacheFile

cli/src/mcp/cache.ts:108–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106 }
107
108 private async readCacheFile(): Promise<CacheFileShape> {
109 try {
110 const raw = await readFile(this.cacheFilePath, 'utf8');
111 const parsed = JSON.parse(raw) as Partial<CacheFileShape>;
112 if (parsed.version !== CACHE_SCHEMA_VERSION || !parsed.entries || typeof parsed.entries !== 'object') {
113 return emptyCacheFile();
114 }
115
116 return {
117 version: CACHE_SCHEMA_VERSION,
118 entries: parsed.entries,
119 };
120 } catch {
121 return emptyCacheFile();
122 }
123 }
124
125 private async writeCacheFile(cache: CacheFileShape): Promise<void> {
126 await mkdir(dirname(this.cacheFilePath), { recursive: true });

Callers 3

readMethod · 0.95
writeMethod · 0.95
clearMethod · 0.95

Calls 1

emptyCacheFileFunction · 0.85

Tested by

no test coverage detected