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

Method ClearNodeCache

pkg/api/client.go:304–321  ·  view source on GitHub ↗

ClearNodeCache selectively invalidates cache entries for a specific node. This is more efficient than clearing the entire cache when only one node's data needs to be refreshed.

(nodeName string)

Source from the content-addressed store, hash-verified

302// This is more efficient than clearing the entire cache when only one node's
303// data needs to be refreshed.
304func (c *Client) ClearNodeCache(nodeName string) {
305 nodePaths := []string{
306 fmt.Sprintf("/nodes/%s/status", nodeName),
307 fmt.Sprintf("/nodes/%s/version", nodeName),
308 fmt.Sprintf("/nodes/%s/config", nodeName),
309 fmt.Sprintf("/nodes/%s/disks/list", nodeName),
310 fmt.Sprintf("/nodes/%s/apt/update", nodeName),
311 }
312
313 for _, path := range nodePaths {
314 cacheKey := fmt.Sprintf("proxmox_api_%s_%s", c.baseURL, path)
315 cacheKey = strings.ReplaceAll(cacheKey, "/", "_")
316
317 _ = c.cache.Delete(cacheKey)
318 }
319
320 c.logger.Debug("Cache entries cleared for node %s", nodeName)
321}
322
323// GetCache returns the cache instance used by this client.
324// This is useful for sharing cache instances across multiple clients in group mode.

Callers 2

GetNodeFromGroupMethod · 0.80

Calls 2

DeleteMethod · 0.65
DebugMethod · 0.65

Tested by

no test coverage detected