> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hopx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cache Management

> Cache management resource for managing execution result cache in HopX sandboxes using the JavaScript/TypeScript SDK. Complete reference for the Cache class including async methods for viewing cache statistics and clearing execution cache. Includes TypeScript examples for cache optimization.

**Version:** 0.1.22\
**Last Verified:** 2025-01-27\
**Package:** `@hopx-ai/sdk` on [npm](https://www.npmjs.com/package/@hopx-ai/sdk)

## Overview

The `Cache` resource provides methods for managing the execution result cache in sandboxes.

## Methods

### `stats`

Get cache statistics.

```typescript theme={null}
async cache.stats(): Promise<CacheStatsResponse>
```

**Returns:** `Promise<CacheStatsResponse>` - Cache statistics

**Example:**

```typescript theme={null}
const stats = await sandbox.cache.stats();
console.log(`Cache hits: ${stats.cache.totalHits}`);
console.log(`Cache size: ${stats.cache.size} / ${stats.cache.maxSize}`);
```

***

### `clear`

Clear the execution result cache.

```typescript theme={null}
async cache.clear(): Promise<CacheClearResponse>
```

<Warning>
  This clears all cached execution results.
</Warning>

***

## Related Classes

* **[Sandbox](/sdk/javascript/sandbox)** - Main sandbox class
* **[Core Concepts: Cache](/core-concepts/cache/statistics)** - Learn about cache management

## See Also

* [Sandbox Class](/sdk/javascript/sandbox) - Access cache via `sandbox.cache`
* [Cache Statistics](/core-concepts/cache/statistics) - Detailed cache documentation

## Related

* **[Python SDK: Cache](/sdk/python/cache)** - Python SDK cache management
* **[Cache Statistics](/core-concepts/cache/statistics)** - Learn about cache statistics
* **[Clearing Cache](/core-concepts/cache/clearing)** - Clear cache to free memory

## Next Steps

* Learn about [Cache Statistics](/core-concepts/cache/statistics) to monitor cache
* Review [Clearing Cache](/core-concepts/cache/clearing) to free memory
* Explore [Code Execution](/core-concepts/code-execution/synchronous) for cached results
* **[CLI System Commands](/cli/commands/system)** - View cache from CLI
