# Redis

#### Integrating Redis with Qyver

This guide outlines the steps required to configure and integrate Redis with Qyver.

**Configuring an Existing Managed Redis Instance**

To use Redis with Qyver, certain Redis modules are required. The easiest way to ensure compatibility is to use the official Redis Stack, which includes all necessary components. Installation instructions can be found in the [official Redis documentation](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/).

Alternatively, you can set up a managed Redis instance through Redis' cloud service, which offers a free tier. For detailed instructions on setting up a managed instance, refer to the **Starting a Managed Redis Instance** section below.

Once your Redis instance is operational, ensure that it is accessible from the server where it will be used. Additionally, configure authentication settings as required.

***

#### Configuration Modifications

To integrate Redis with Qyver, you need to include the `RedisVectorDatabase` class in your configuration. The following example demonstrates how to set it up:

```python
from qyver import framework as qv

vector_database = qv.RedisVectorDatabase(
    "<your_redis_host>",  # (Required) Redis URL without port or additional fields.
    12315,  # (Required) The Redis port (must be an integer).
    default_query_limit=10,  # (Optional) Defines the maximum number of query results. Defaults to 10 if not specified.
    # Additional parameters can be provided as keyword arguments. These settings should follow the official Python Redis client configuration.
    # Refer to the documentation here: https://redis.readthedocs.io/en/stable/connections.html.
    # Example of basic authentication:
    username="test",
    password="password"
)
```

Once the vector database is configured, assign it to the executor:

```python
...
executor = qv.RestExecutor(
    sources=[source],
    indices=[index],
    queries=[qv.RestQuery(qv.RestDescriptor("query"), query)],
    vector_database=vector_database  # Assign the configured RedisVectorDatabase instance
)
...
```

***

#### Starting a Managed Redis Instance

To create a managed Redis instance, sign in to [Redis Labs](https://app.redislabs.com/) and click **New Database**. On the setup page, locate the **Type** selector and choose **Redis Stack** (this is the default selection). If not selected, ensure Redis Stack is chosen.

For basic usage, no additional configurations are required. A default user and password are automatically generated. If you plan to use the instance for persistent data storage beyond temporary use, consider enabling **High Availability (HA)**, data persistence, and other relevant settings.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qyverlabs.gitbook.io/qyverlabs-docs/run-in-production/supported-vector-databases/redis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
