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

# RedisStorageAdapter

> Redis-based storage adapter API reference

Redis-based storage adapter for distributed caching.

## Constructor

```ts theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
constructor(config: RedisStorageConfig)
```

### RedisStorageConfig

```ts theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
interface RedisStorageConfig {
  client: RedisClient;
  namespace?: string;
  ttl?: number;
  keyPrefix?: string;
}
```

| Option      | Type          | Default        | Description               |
| ----------- | ------------- | -------------- | ------------------------- |
| `client`    | `RedisClient` | **required**   | Redis client instance     |
| `namespace` | `string`      | `'default'`    | Namespace for isolation   |
| `ttl`       | `number`      | `86400`        | TTL in seconds (24 hours) |
| `keyPrefix` | `string`      | `'vectoriadb'` | Redis key prefix          |

### RedisClient Interface

```ts theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
interface RedisClient {
  get(key: string): Promise<string | null>;
  set(key: string, value: string): Promise<void | string>;
  setex(key: string, seconds: number, value: string): Promise<void | string>;
  del(key: string): Promise<number>;
  ping(): Promise<string>;
  quit(): Promise<void>;
}
```

Compatible with ioredis, node-redis, and similar clients.

## Example

```ts theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
import { VectoriaDB, RedisStorageAdapter } from 'vectoriadb';
import Redis from 'ioredis';

const redisClient = new Redis();

const db = new VectoriaDB({
  storageAdapter: new RedisStorageAdapter({
    client: redisClient,
    namespace: 'my-index',
    ttl: 86400,
  }),
});
```

## Key Structure

Redis key format: `{keyPrefix}:{namespace}`

Example: `vectoriadb:my-index`

## Methods

| Method                    | Description                          |
| ------------------------- | ------------------------------------ |
| `initialize()`            | Test Redis connection                |
| `load()`                  | Load embeddings from Redis           |
| `save(data)`              | Save embeddings with TTL             |
| `hasValidCache(metadata)` | Check if valid cache exists          |
| `clear()`                 | Delete Redis key                     |
| `close()`                 | No-op (client lifecycle is external) |

## Security

The adapter includes command injection protection:

* Namespace is sanitized to remove control characters
* Key prefix is sanitized similarly

## Related

<CardGroup cols={3}>
  <Card title="FileStorageAdapter" icon="file" href="/vectoriadb/api-reference/storage-adapters/file-adapter">
    File storage
  </Card>

  <Card title="MemoryStorageAdapter" icon="memory" href="/vectoriadb/api-reference/storage-adapters/memory-adapter">
    Memory storage
  </Card>

  <Card title="Storage Guide" icon="floppy-disk" href="/vectoriadb/guides/storage/redis-adapter">
    Redis adapter guide
  </Card>
</CardGroup>
