Angular Modernizer
    Preparing search index...

    Multi-cache fallback manager that checks multiple cache directories in order.

    Wraps several CacheManager instances. Used by scan-all to read the results of the individual tool caches (solid, angular, architecture) when its own directory has no entry, so scan-all after individual scans does not analyze those files again.

    Architecture:

    • Primary cache: First cache directory (e.g., 'all')
    • Fallback caches: Additional cache directories (e.g., 'solid', 'angular', 'architecture')
    • UNIDIRECTIONAL: Only scan-all reads from individual caches, not vice versa

    Cache Read Strategy:

    1. Check primary cache (.angular-modernizer-cache/all/)
    2. If not found, check fallback caches in order
    3. First cache with valid entry wins (no merging)

    Cache Write Strategy:

    • All writes go to primary cache only
    • Fallback caches are read-only from this manager's perspective
    // In scan-all.ts
    const cacheManager = new MultiCacheFallbackManager(
    fileSystem,
    ['all', 'solid', 'angular', 'architecture'], // Check in this order
    { cacheDir: '.angular-modernizer-cache' }
    );

    // Try to read from any cache (primary or fallbacks)
    const cached = await cacheManager.getAnalysisResult(filePath);
    if (cached) {
    console.info(`✓ ${filePath} (from ${cached.source} cache)`);
    }

    // Write always goes to primary cache
    await cacheManager.setAnalysisResult(filePath, results);
    Index

    Constructors

    • Create a multi-cache fallback manager.

      Parameters

      • fileSystem: FileSystemAdapter

        File system adapter

      • cacheDirNames: string[]

        Cache directory names in priority order (first = primary)

      • OptionalbaseConfig: Partial<CacheConfig>

        Base cache configuration (merged with per-cache settings)

      Returns MultiCacheFallbackManager

      const manager = new MultiCacheFallbackManager(
      fileSystem,
      ['all', 'solid', 'angular', 'architecture'],
      { cacheDir: '.angular-modernizer-cache' }
      );

    Methods

    • Clear all caches (all directories).

      Use with caution: This clears PRIMARY and ALL FALLBACK caches.

      Returns Promise<void>

    • Get all cache managers (for advanced operations).

      Returns { manager: CacheManager; name: string }[]

      • manager: CacheManager

        Cache manager for the directory.

      • name: string

        Cache directory name.

    • Get cache statistics for ALL caches (primary + fallbacks).

      Useful for debugging and understanding overall cache usage.

      Returns { name: string; stats: CacheStats }[]

      Array of cache stats with cache names

      • name: string

        Cache directory name.

      • stats: CacheStats

        Statistics of that cache.

    • Get cached analysis result from any cache (primary or fallbacks).

      Search Strategy:

      1. Check primary cache first (most likely to be valid)
      2. If not found, check fallback caches in order
      3. Return first valid cache entry found
      4. Automatic cache invalidation applies (mtime/hash checking)

      Performance:

      • Fast path: Primary cache hit (no fallback checks)
      • Fallback path: Check fallbacks sequentially until found
      • Worst case: Check all caches (still faster than re-analysis)

      Parameters

      • filePath: string

        File path to look up

      Returns Promise<CachedAnalysisResult & { source?: string } | null>

      Cached result with source cache name, or null if not found in any cache

    • Get cache statistics for PRIMARY cache only.

      Why primary only?

      • Stats track hits/misses for this manager's usage
      • Fallback caches have their own stats when used directly
      • Prevents double-counting across caches

      Returns CacheStats

      Cache statistics for primary cache

    • Initialize all cache managers.

      Returns Promise<void>

    • Invalidate cache for a file (invalidates in ALL caches).

      Why invalidate all caches?

      • File change affects all cached analysis results for that file
      • Ensures consistency across all cache directories
      • Next scan will re-analyze fresh and update its specific cache

      Parameters

      • filePath: string

        File path to invalidate

      • Optionaltype: "analysis" | "ast"

        Cache type to invalidate (default: both ast and analysis)

      Returns Promise<void>

    • Cache analysis results (writes to PRIMARY cache only).

      Write Strategy:

      • All writes go to primary cache (first in list)
      • Fallback caches are NOT updated by this manager
      • Individual scans update their own caches independently

      Why primary-only writes?

      • Prevents cross-contamination (scan-all shouldn't write to solid cache)
      • Individual scans remain authoritative for their own caches
      • Simpler cache consistency model

      Parameters

      • filePath: string

        File path to cache

      • results: unknown[]

        Analysis results to cache

      • dependencies: string[] = []

        File dependencies (for invalidation)

      Returns Promise<void>