(cachePath: string, content: CacheFile)
| 35 | } |
| 36 | |
| 37 | function writeCacheFile(cachePath: string, content: CacheFile): void { |
| 38 | try { |
| 39 | const dir = path.dirname(cachePath) |
| 40 | if (!fs.existsSync(dir)) { |
| 41 | fs.mkdirSync(dir, { recursive: true }) |
| 42 | } |
| 43 | fs.writeFileSync(cachePath, JSON.stringify(content), 'utf-8') |
| 44 | } catch { |
| 45 | // Write failure is non-fatal |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | export function getCache<T>(sessionId: string, key: string, cacheDir: string): T | null { |
| 50 | const cachePath = getCachePath(sessionId, cacheDir) |
no outgoing calls
no test coverage detected