* Clear all registered caches in priority order. * Lower priority values are cleared first. * @param options Optional configuration
(options: ClearAllOptions = {})
| 112 | * @param options Optional configuration |
| 113 | */ |
| 114 | clearAll(options: ClearAllOptions = {}): void { |
| 115 | // Guard against re-entry (some clear functions might trigger events) |
| 116 | if (this.isClearing) { |
| 117 | appLogger.warn('[CacheManager] clearAll already in progress, skipping'); |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | this.isClearing = true; |
| 122 | const startTime = performance.now(); |
| 123 | |
| 124 | try { |
| 125 | // Build sorted list respecting priorities and dependencies |
| 126 | const sortedEntries = this.topologicalSort(options); |
| 127 | |
| 128 | // Clear each cache, catching errors to ensure all caches get cleared |
| 129 | for (const entry of sortedEntries) { |
| 130 | try { |
| 131 | entry.clear(); |
| 132 | } catch (err) { |
| 133 | appLogger.error(`[CacheManager] Error clearing "${entry.name}":`, err); |
| 134 | // Continue clearing other caches |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | const elapsed = performance.now() - startTime; |
| 139 | appLogger.info(`[CacheManager] Cleared ${sortedEntries.length} caches in ${elapsed.toFixed(1)}ms`); |
| 140 | } finally { |
| 141 | this.isClearing = false; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Clear specific caches by name. |
no test coverage detected