MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / loadFromCache

Function loadFromCache

internal/repoconfig/repoconfig.go:297–312  ·  view source on GitHub ↗
(url string, kind entities.Kind, cache camconfig.CacheConfig)

Source from the content-addressed store, hash-verified

295}
296
297func loadFromCache(url string, kind entities.Kind, cache camconfig.CacheConfig) (map[string]RepoEntry, error) {
298 path := cacheFilePath(url, kind, cache)
299 info, err := os.Stat(path)
300 if err != nil {
301 return nil, err
302 }
303 age := time.Since(info.ModTime())
304 if age > time.Duration(cache.TTLSeconds)*time.Second {
305 return nil, fmt.Errorf("cache expired")
306 }
307 data, err := os.ReadFile(path)
308 if err != nil {
309 return nil, err
310 }
311 return parseRepoJSON(data)
312}
313
314func saveToCache(url string, kind entities.Kind, cache camconfig.CacheConfig, data []byte) error {
315 path := cacheFilePath(url, kind, cache)

Callers 1

loadRemoteWithCacheFunction · 0.85

Calls 3

cacheFilePathFunction · 0.85
parseRepoJSONFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected