Skip to main content
Monitor the execution result cache to understand cache performance, optimize your code patterns, and track cache usage over time.

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:

Understanding Cache Metrics

Cache Size and Hits

Monitor cache usage and performance:

Cache Size

Monitor cache size to ensure it’s not consuming excessive resources:

Monitoring Cache Performance

Track cache performance over time:

Cache Statistics Response

The cache statistics response includes:

Field Descriptions

  • cache.max_size: Maximum cache size limit
  • cache.size: Current cache size
  • cache.total_hits: Total number of cache hits (cached results reused)
  • cache.ttl: Time-to-live for cache entries
  • timestamp: Timestamp when the statistics were retrieved

Use Cases

Optimizing for Cache

Test cache effectiveness with repeated executions:

Monitoring Cache Growth

Track how cache grows over time:

Best Practices

Monitor total hits to understand cache effectiveness. A high number of total hits indicates good cache utilization.
Cache works best with deterministic code. Code that produces the same output for the same input will benefit most from caching.
Cache size can grow over time. Monitor cache size and clear it periodically if it becomes too large.
Environment variables affect caching. Code with different environment variables will have separate cache entries.

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

Next Steps