Overview
HopX caches execution results to improve performance for repeated code executions. Cache statistics help you:- Monitor cache hit rates
- Track cache size and entry counts
- Optimize code patterns for better caching
- Understand cache effectiveness
The cache stores execution results based on code content and environment. Identical code executions with the same environment variables will hit the cache.
Getting Cache Statistics
Retrieve current cache statistics:- Python
- JavaScript
Understanding Cache Metrics
Cache Size and Hits
Monitor cache usage and performance:- Python
- JavaScript
Cache Size
Monitor cache size to ensure it’s not consuming excessive resources:- Python
- JavaScript
Monitoring Cache Performance
Track cache performance over time:- Python
- JavaScript
Cache Statistics Response
The cache statistics response includes:Field Descriptions
cache.max_size: Maximum cache size limitcache.size: Current cache sizecache.total_hits: Total number of cache hits (cached results reused)cache.ttl: Time-to-live for cache entriestimestamp: Timestamp when the statistics were retrieved
Use Cases
Optimizing for Cache
Test cache effectiveness with repeated executions:- Python
- JavaScript
Monitoring Cache Growth
Track how cache grows over time:- Python
- JavaScript
Best Practices
API Reference
Python SDK
sandbox.cache.stats(*, timeout=None)- Get cache statistics
JavaScript SDK
sandbox.cache.stats()- Get cache statistics
API Endpoint
- GET
/cache/stats- Get execution cache statistics
Related
- Clearing Cache - Clear cache to free memory
- SDK: sandbox.cache.stats() - Python SDK method
- API: GET /cache/stats - VM Agent API endpoint
Next Steps
- Learn about Clearing Cache to free memory
- Review Code Execution to see cached results
- Clearing Cache - Clear the execution cache
- CLI System Commands - View cache statistics from CLI

