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

# Camel.storages.key value storages.redis

<a id="camel.storages.key_value_storages.redis" />

<a id="camel.storages.key_value_storages.redis.RedisStorage" />

## RedisStorage

```python theme={"system"}
class RedisStorage(BaseKeyValueStorage):
```

A concrete implementation of the :obj:`BaseCacheStorage` using Redis as
the backend. This is suitable for distributed cache systems that require
persistence and high availability.

<a id="camel.storages.key_value_storages.redis.RedisStorage.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    sid: str,
    url: str = 'redis://localhost:6379',
    loop: Optional[asyncio.AbstractEventLoop] = None,
    **kwargs
):
```

Initializes the RedisStorage instance with the provided URL and
options.

**Parameters:**

* **sid** (str): The ID for the storage instance to identify the record space.
* **url** (str): The URL for connecting to the Redis server. \*\*kwargs: Additional keyword arguments for Redis client configuration.

<a id="camel.storages.key_value_storages.redis.RedisStorage.__enter__" />

### **enter**

```python theme={"system"}
def __enter__(self):
```

<a id="camel.storages.key_value_storages.redis.RedisStorage.__exit__" />

### **exit**

```python theme={"system"}
def __exit__(
    self,
    exc_type,
    exc,
    tb
):
```

<a id="camel.storages.key_value_storages.redis.RedisStorage._create_client" />

### \_create\_client

```python theme={"system"}
def _create_client(self, **kwargs):
```

Creates the Redis client with the provided URL and options.

<a id="camel.storages.key_value_storages.redis.RedisStorage.client" />

### client

```python theme={"system"}
def client(self):
```

**Returns:**

redis.asyncio.Redis: The Redis client instance.

<a id="camel.storages.key_value_storages.redis.RedisStorage.save" />

### save

```python theme={"system"}
def save(
    self,
    records: List[Dict[str, Any]],
    expire: Optional[int] = None
):
```

Saves a batch of records to the key-value storage system.

<a id="camel.storages.key_value_storages.redis.RedisStorage.load" />

### load

```python theme={"system"}
def load(self):
```

**Returns:**

List\[Dict\[str, Any]]: A list of dictionaries, where each dictionary
represents a stored record.

<a id="camel.storages.key_value_storages.redis.RedisStorage.clear" />

### clear

```python theme={"system"}
def clear(self):
```

Removes all records from the key-value storage system.

<a id="camel.storages.key_value_storages.redis.RedisStorage._run_async" />

### \_run\_async

```python theme={"system"}
def _run_async(self, coro):
```
