MCPcopy Index your code
hub / github.com/coder/coder / cachedModelConfig

Method cachedModelConfig

coderd/x/chatd/configcache.go:243–261  ·  view source on GitHub ↗
(id uuid.UUID)

Source from the content-addressed store, hash-verified

241}
242
243func (c *chatConfigCache) cachedModelConfig(id uuid.UUID) (database.ChatModelConfig, bool) {
244 c.mu.RLock()
245 entry, ok := c.modelConfigs[id]
246 c.mu.RUnlock()
247 if !ok {
248 return database.ChatModelConfig{}, false
249 }
250 if c.clock.Now().Before(entry.expiresAt) {
251 return cloneModelConfig(entry.config), true
252 }
253
254 c.mu.Lock()
255 if current, ok := c.modelConfigs[id]; ok && !c.clock.Now().Before(current.expiresAt) {
256 delete(c.modelConfigs, id)
257 }
258 c.mu.Unlock()
259
260 return database.ChatModelConfig{}, false
261}
262
263func (c *chatConfigCache) modelConfigSnapshot() modelConfigSnapshot {
264 c.mu.RLock()

Callers 1

ModelConfigByIDMethod · 0.95

Calls 3

cloneModelConfigFunction · 0.85
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected