MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / modelsCacheFile

Function modelsCacheFile

internal/plugins/ai/openai/models_cache.go:43–48  ·  view source on GitHub ↗

modelsCacheFile derives a stable, collision-resistant cache path from the provider name and the full request URL. The URL is hashed so a provider that changes its endpoint does not read a stale entry from the old one.

(dir, providerName, fullURL string)

Source from the content-addressed store, hash-verified

41// provider name and the full request URL. The URL is hashed so a provider that
42// changes its endpoint does not read a stale entry from the old one.
43func modelsCacheFile(dir, providerName, fullURL string) string {
44 sum := sha256.Sum256([]byte(fullURL))
45 slug := cacheNameSanitizer.ReplaceAllString(providerName, "_")
46 name := fmt.Sprintf("%s-%s.json", slug, hex.EncodeToString(sum[:])[:12])
47 return filepath.Join(dir, name)
48}
49
50// readModelsCache returns the cached model list for (providerName, fullURL).
51// When maxAge > 0 the entry must be younger than maxAge; maxAge <= 0 accepts an

Callers 3

writeAgedCacheFunction · 0.85
readModelsCacheFunction · 0.85
writeModelsCacheFunction · 0.85

Calls

no outgoing calls

Tested by 1

writeAgedCacheFunction · 0.68