MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / flushModels

Function flushModels

src/api/providers/fetchers/modelCache.ts:410–423  ·  view source on GitHub ↗
(options: GetModelsOptions, refresh: boolean = false)

Source from the content-addressed store, hash-verified

408 * @param refresh - If true, immediately fetch fresh data from API
409 */
410export const flushModels = async (options: GetModelsOptions, refresh: boolean = false): Promise<void> => {
411 if (refresh) {
412 // Don't delete memory cache - let refreshModels atomically replace it
413 // This prevents a race condition where getModels() might be called
414 // before refresh completes, avoiding a gap in cache availability
415 // Await the refresh to ensure the cache is updated before returning
416 await refreshModels(options)
417 } else {
418 // Only delete memory cache when not refreshing. Use the compound cache key so that
419 // URL-scoped providers (litellm, poe, etc.) actually evict the per-server entry rather
420 // than a bare provider-name entry that was never written.
421 memoryCache.del(getCacheKey(options))
422 }
423}
424
425/**
426 * Get models from cache, checking memory first, then disk.

Callers 2

webviewMessageHandlerFunction · 0.90

Calls 2

refreshModelsFunction · 0.85
getCacheKeyFunction · 0.70

Tested by

no test coverage detected