ClearClusterCache selectively invalidates cluster-level cache entries instead of wiping the entire cache. This preserves node-level cached data (disks, updates) that rarely changes, avoiding unnecessary API round-trips during refresh.
()
| 282 | // data (disks, updates) that rarely changes, avoiding unnecessary API |
| 283 | // round-trips during refresh. |
| 284 | func (c *Client) ClearClusterCache() { |
| 285 | clusterPaths := []string{ |
| 286 | "/cluster/status", |
| 287 | "/cluster/resources", |
| 288 | "/cluster/tasks", |
| 289 | } |
| 290 | |
| 291 | for _, path := range clusterPaths { |
| 292 | cacheKey := fmt.Sprintf("proxmox_api_%s_%s", c.baseURL, path) |
| 293 | cacheKey = strings.ReplaceAll(cacheKey, "/", "_") |
| 294 | |
| 295 | _ = c.cache.Delete(cacheKey) |
| 296 | } |
| 297 | |
| 298 | c.logger.Debug("Cluster-level cache entries cleared selectively") |
| 299 | } |
| 300 | |
| 301 | // ClearNodeCache selectively invalidates cache entries for a specific node. |
| 302 | // This is more efficient than clearing the entire cache when only one node's |
no test coverage detected