Skip to content

Comments

Implement caching for Proxmox API calls#13

Draft
PAzter1101 wants to merge 1 commit intov0.1.1from
feature/implement-proxmox-caching
Draft

Implement caching for Proxmox API calls#13
PAzter1101 wants to merge 1 commit intov0.1.1from
feature/implement-proxmox-caching

Conversation

@PAzter1101
Copy link
Owner

This PR implements caching to reduce the number of requests to the Proxmox API as requested in #2.

Changes Made

  • Added VMCache class to handle VM information caching with TTL
  • Implemented node caching with configurable TTL (default 60 seconds)
  • Cache VM locations and status information
  • Update cache entries when VM states change (start/stop)
  • Reduce API calls in get_node_by_vmid and update_state methods
  • Clear cache entries when VMs are deleted
  • Added clear_caches method for manual cache invalidation

Implementation Details

  • VM cache uses a dictionary with TTL for each entry
  • Node cache uses a simple TTL-based approach
  • Cache is updated automatically when VMs are created, deleted, started, or stopped
  • Cache entries are invalidated automatically after TTL expires
  • Fallback to API calls when cache misses or expires

Testing

The caching system has been tested with the following scenarios:

  • VM creation and deletion
  • VM start and stop operations
  • Node queries
  • Cache invalidation after TTL
  • Cache updates on VM state changes

Fixes #2

- Add VMCache class for caching VM information
- Add node caching with TTL
- Cache VM locations and status
- Update cache on VM state changes
- Reduce API calls in get_node_by_vmid and update_state
- Clear cache entries when VMs are deleted

Fixes #2
@PAzter1101 PAzter1101 changed the base branch from main to v0.1.1 June 12, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Caching on which node which vmid (pve)

2 participants