Skip to main content
Clear the execution result cache to free memory, reset cache statistics, and ensure fresh executions for testing or debugging.

Overview

Clearing the cache is useful when:
  • Cache has grown too large and you need to free memory
  • You want to reset cache statistics
  • Testing code changes that should bypass cache
  • Debugging cache-related issues
  • Starting fresh after code modifications
Clearing the cache will remove all cached execution results. Subsequent executions will be cache misses until new entries are created.

Clearing Cache

Clear all cached execution results:

Cache Clear Response

The cache clear operation returns a confirmation:

Field Descriptions

  • message: Confirmation message
  • timestamp: Timestamp when the cache was cleared

Use Cases

Freeing Memory

Clear cache when it consumes too much memory:

Resetting for Testing

Clear cache before running tests to ensure fresh executions:

Periodic Cache Maintenance

Clear cache periodically to prevent unbounded growth:

Best Practices

Monitor cache size before clearing. Only clear when necessary to avoid losing beneficial cached results.
Clear cache before testing to ensure code changes are properly tested without cache interference.
Clearing cache affects performance. After clearing, all executions will be cache misses until new entries are created.
Set up periodic cache maintenance if you have long-running sandboxes with many executions.

API Reference

Python SDK

  • sandbox.cache.clear(*, timeout=None) - Clear execution cache

JavaScript SDK

  • sandbox.cache.clear() - Clear execution cache

API Endpoint

  • POST /cache/clear - Clear execution result cache

Next Steps