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

# Cache

> Response caching for LLM calls

# Cache

Cache provides response caching to reduce API costs and improve response times.

## Available Providers

| Provider      | Description                 |
| ------------- | --------------------------- |
| `MemoryCache` | In-memory cache             |
| `FileCache`   | File-based persistent cache |

## Quick Start

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { createMemoryCache, createFileCache } from 'praisonai';

// Memory cache
const memCache = createMemoryCache({
  maxSize: 1000,
  ttl: 3600000  // 1 hour
});

// File cache
const fileCache = createFileCache({
  directory: './cache',
  ttl: 86400000  // 24 hours
});
```

## Configuration

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
interface CacheConfig {
  maxSize?: number;
  ttl?: number;  // Time to live in ms
}
```

## Usage with Agents

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, createMemoryCache } from 'praisonai';

const cache = createMemoryCache({ ttl: 3600000 });

const agent = new Agent({
  name: 'CachedAgent',
  instructions: 'You are helpful.',
  cache
});

// First call - hits API
const response1 = await agent.chat('Hello');

// Second call - returns cached response
const response2 = await agent.chat('Hello');
```

## CLI Usage

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai-ts cache info
praisonai-ts cache providers --json
```
