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

Method Delete

internal/cache/cache.go:267–288  ·  view source on GitHub ↗

Delete removes an item from the cache.

(key string)

Source from the content-addressed store, hash-verified

265
266// Delete removes an item from the cache.
267func (c *FileCache) Delete(key string) error {
268 c.mutex.Lock()
269 defer c.mutex.Unlock()
270
271 // Remove from in-memory cache and LRU list
272 if element, exists := c.inMemory[key]; exists {
273 c.lruList.Remove(element)
274 delete(c.inMemory, key)
275 }
276
277 // If persisted, remove the file
278 if c.persisted {
279 filePath := filepath.Join(c.dir, key+".json")
280 if err := os.Remove(filePath); err != nil && !os.IsNotExist(err) {
281 return fmt.Errorf("failed to remove cache file: %w", err)
282 }
283 }
284
285 getCacheLogger().Debug("Deleted cache item: %s", key)
286
287 return nil
288}
289
290// Clear removes all items from the cache.
291func (c *FileCache) Clear() error {

Callers

nothing calls this directly

Calls 2

getCacheLoggerFunction · 0.85
DebugMethod · 0.65

Tested by

no test coverage detected