MCPcopy Index your code
hub / github.com/coder/mux / writeCacheToDisk

Method writeCacheToDisk

src/node/services/experimentsService.ts:385–411  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

383 }
384
385 private async writeCacheToDisk(): Promise<void> {
386 try {
387 const experiments: ExperimentsCacheFile["experiments"] = {};
388 for (const [experimentId, cached] of this.cachedVariants) {
389 experiments[experimentId] = {
390 value: cached.value,
391 fetchedAtMs: cached.fetchedAtMs,
392 };
393 }
394
395 const overrides: NonNullable<ExperimentsCacheFile["overrides"]> = {};
396 for (const [experimentId, enabled] of this.overrides) {
397 overrides[experimentId] = enabled;
398 }
399
400 const payload: ExperimentsCacheFile = {
401 version: CACHE_FILE_VERSION,
402 experiments,
403 overrides,
404 };
405
406 await fs.mkdir(this.muxHome, { recursive: true });
407 await writeFileAtomic(this.cacheFilePath, JSON.stringify(payload, null, 2), "utf-8");
408 } catch {
409 // Ignore cache persistence failures
410 }
411 }
412}

Callers 2

setOverrideMethod · 0.95
refreshExperimentImplMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected