MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / evictLRU

Method evictLRU

internal/cache/cache.go:245–264  ·  view source on GitHub ↗

evictLRU removes the least recently used item from the cache. Must be called with mutex held.

()

Source from the content-addressed store, hash-verified

243// evictLRU removes the least recently used item from the cache.
244// Must be called with mutex held.
245func (c *FileCache) evictLRU() {
246 element := c.lruList.Back()
247 if element == nil {
248 return
249 }
250
251 entry := element.Value.(*lruEntry)
252 c.lruList.Remove(element)
253 delete(c.inMemory, entry.key)
254
255 getCacheLogger().Debug("Evicted LRU item: %s (cache size limit: %d)", entry.key, c.maxSize)
256
257 // If persisted, remove the file
258 if c.persisted {
259 filePath := filepath.Join(c.dir, entry.key+".json")
260 if err := os.Remove(filePath); err != nil && !os.IsNotExist(err) {
261 getCacheLogger().Debug("Failed to remove evicted cache file: %v", err)
262 }
263 }
264}
265
266// Delete removes an item from the cache.
267func (c *FileCache) Delete(key string) error {

Callers 1

SetMethod · 0.95

Calls 2

getCacheLoggerFunction · 0.85
DebugMethod · 0.65

Tested by

no test coverage detected