Last Verified: 2025-01-27
Package:
hopx-ai on PyPI
Overview
TheCache resource provides methods for managing the execution result cache in sandboxes. The cache stores execution results to improve performance for repeated code executions. Use this resource to view cache statistics and clear the cache when needed.
Access
Methods
stats
Get cache statistics.
Dict[str, Any] - Cache statistics dictionary with:
cache.total_hits(int): Total cache hitscache.size(int): Current cache sizecache.max_size(int): Maximum cache sizecache.ttl(int): Time-to-live in secondstimestamp(str): Timestamp of the statistics
clear
Clear the execution result cache.
Dict[str, Any] - Confirmation message
Example:
Examples
Example 1: Viewing Cache Statistics
Example 2: Clearing Cache
Example 3: Monitoring Cache Usage
Related Classes
- Sandbox - Main sandbox class
- Core Concepts: Cache - Learn about cache management
See Also
- Sandbox Class - Access cache via
sandbox.cache - Cache Statistics - Detailed cache documentation
Related
- Code Execution - Execution results are cached
- API: Cache Management - VM Agent API endpoints
Next Steps
- Learn about Code Execution to see cached results
- Review Cache Statistics for detailed cache information
- CLI Cache - View cache statistics from CLI

