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

Method loadOnce

internal/desktop/tool_cache.go:56–74  ·  view source on GitHub ↗

loadOnce reads the on-disk cache into memory the first time it is called. Best-effort: a missing or corrupt file leaves the cache empty so callers fall through to a fresh probe.

()

Source from the content-addressed store, hash-verified

54// Best-effort: a missing or corrupt file leaves the cache empty so callers
55// fall through to a fresh probe.
56func (c *detectionCache) loadOnce() {
57 c.mu.Lock()
58 defer c.mu.Unlock()
59 if c.loaded {
60 return
61 }
62 c.loaded = true
63 raw, err := os.ReadFile(c.path)
64 if err != nil {
65 return
66 }
67 var file detectionCacheFile
68 if err := json.Unmarshal(raw, &file); err != nil {
69 return
70 }
71 for name, entry := range file.Tools {
72 c.entries[name] = entry
73 }
74}
75
76// get returns the cached entry for name and whether it is still fresh
77// (within detectionTTL). A stale or missing entry reports fresh=false so the

Calls 1

ReadFileMethod · 0.80