import { GlobalConfig } from '../../../config/global.ts'; import { instrument } from '../../../instrumentation/index.ts'; import { logger } from '../../../logger/index.ts'; import { RepoCacheNull } from './impl/null.ts'; import type { RepoCache, RepoCacheData } from './types.ts'; // This will be overwritten with initRepoCache() // Used primarily as a placeholder and for testing let repoCache: RepoCache = new RepoCacheNull(); export function resetCache(): void { setCache(new RepoCacheNull()); } export function setCache(cache: RepoCache): void { repoCache = cache; } export function getCache(): RepoCacheData { return repoCache.getData(); } export async function saveCache(): Promise { if (GlobalConfig.get('dryRun')) { logger.info(`DRY-RUN: Would save repository cache.`); } else { await instrument('save RepoCache', () => repoCache.save()); } } export function isCacheModified(): boolean | undefined { return repoCache.isModified(); }