MCPcopy Create free account
hub / github.com/bytebase/bytebase / Set

Method Set

backend/api/lsp/performance_optimizer.go:227–255  ·  view source on GitHub ↗

Set stores content in cache with LRU eviction

(uri string, content *CachedContent)

Source from the content-addressed store, hash-verified

225
226// Set stores content in cache with LRU eviction
227func (c *ContentCache) Set(uri string, content *CachedContent) {
228 c.mu.Lock()
229 defer c.mu.Unlock()
230
231 // Check if already exists
232 if _, exists := c.cache[uri]; exists {
233 // If already exists, just update and move to end
234 for i, u := range c.order {
235 if u == uri {
236 // More efficient removal for common case of updating existing entry
237 copy(c.order[i:], c.order[i+1:])
238 c.order = c.order[:len(c.order)-1]
239 break
240 }
241 }
242 }
243
244 // Add to end (most recently used)
245 c.order = append(c.order, uri)
246
247 // Evict oldest if over capacity
248 if len(c.order) > c.maxEntries {
249 oldest := c.order[0]
250 delete(c.cache, oldest)
251 c.order = c.order[1:]
252 }
253
254 c.cache[uri] = content
255}

Callers 15

UserInfoMethod · 0.45
newMockServerFunction · 0.45
GetOpenIDConfigurationFunction · 0.45
newMockServerFunction · 0.45
VisitMethod · 0.45
getMethod · 0.45
DoMethod · 0.45
QueryConnMethod · 0.45
PostMethod · 0.45
postMessageFunction · 0.45
getTokenFunction · 0.45

Calls

no outgoing calls

Tested by 15

newMockServerFunction · 0.36
newMockServerFunction · 0.36
handlerMethod · 0.36
TestMCPAuthMiddlewareFunction · 0.36
mockListDatabasesFunction · 0.36
mockQueryServerFunction · 0.36