(id uuid.UUID)
| 241 | } |
| 242 | |
| 243 | func (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 | |
| 263 | func (c *chatConfigCache) modelConfigSnapshot() modelConfigSnapshot { |
| 264 | c.mu.RLock() |
no test coverage detected