Caching System
Module Fetch Optimization
The CacheManagerService optimizes blueprint loading by caching marketplace modules locally.
Purpose
Avoid redundant network requests or file system scans when loading blueprints.
Implementation
// src/core/services/infrastructure/cache/cache-manager.ts
export class CacheManagerService {
private cacheDir: string;
async getCachedBlueprint(moduleId: string): Promise<Blueprint | null> {
const cachePath = join(this.cacheDir, moduleId, 'blueprint.ts');
if (existsSync(cachePath)) {
return await import(cachePath);
}
return null;
}
async cacheBlueprint(moduleId: string, blueprint: Blueprint): Promise<void> {
const cachePath = join(this.cacheDir, moduleId);
await fs.promises.mkdir(cachePath, { recursive: true });
await fs.promises.writeFile(
join(cachePath, 'blueprint.ts'),
JSON.stringify(blueprint)
);
}
}Cache Strategy
- First load: Fetch from marketplace → cache locally
- Subsequent loads: Load from cache
- Cache invalidation: On marketplace update or explicit clear
Location: ~/.architech/cache/