# API Reference

> API reference for @anymux/cache.

Source: https://anymux-docs.n.yatsyk.com/docs/cache/api

# API Reference

## `CachedFileSystem`

Wraps an `IFileSystem` with an in-memory cache layer.

### Constructor

```ts
new CachedFileSystem(options: CachedFileSystemOptions)
```

### Options

| Option    | Type          | Description                      |
| --------- | ------------- | -------------------------------- |
| `fs`      | `IFileSystem` | The file system to cache         |
| `ttl`     | `number?`     | Cache TTL in milliseconds        |
| `maxSize` | `number?`     | Maximum number of cached entries |

### Methods

Implements all `IFileSystem` methods: `readFile`, `writeFile`, `readDir`, `stat`, `mkdir`, `rm`, `exists`.

### Additional Methods

| Method             | Description                       |
| ------------------ | --------------------------------- |
| `invalidate(path)` | Remove a specific path from cache |
| `clear()`          | Clear the entire cache            |
