Skip to main content
Version: 0.3.0
Last Verified: 2025-01-27
Package: hopx-ai on PyPI

Overview

The Cache 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.
Returns: Dict[str, Any] - Cache statistics dictionary with:
  • cache.total_hits (int): Total cache hits
  • cache.size (int): Current cache size
  • cache.max_size (int): Maximum cache size
  • cache.ttl (int): Time-to-live in seconds
  • timestamp (str): Timestamp of the statistics
Example:

clear

Clear the execution result cache.
Returns: Dict[str, Any] - Confirmation message
This clears all cached execution results. Subsequent executions will not benefit from cached results until cache is repopulated.
Example:
See Also:

Examples

Example 1: Viewing Cache Statistics

Example 2: Clearing Cache

Example 3: Monitoring Cache Usage


See Also

Next Steps