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

# Redis Source

> Redis Change Data Capture Setup with Streamkap

## Prerequisites

* Redis version ≥ 6.0
* A Redis user with sufficient privileges to read data and manage keyspace notifications
* Keyspace notifications enabled for change data capture

## Redis Setup

### 1. Grant Database Access

* Configure one of the [Connection Options](/connection-options) to ensure Streamkap can reach your Redis instance.

### 2. Enable Keyspace Notifications

Keyspace notifications allow clients to receive events affecting the Redis data set in some way. The Connector relies on Redis keyspace notifications for capturing changes.

Set the following parameter in your Redis configuration:

* `notify-keyspace-events = KEA`

This enables:

* **K**: Keyspace events, published with `__keyspace@<db>__` prefix
* **E**: Keyevent events, published with `__keyevent@<db>__` prefix
* **A**: Alias for all event types (g\$lshzxe)

<Info>
  **Keyspace notifications and performance**

  Enabling keyspace notifications may impact Redis performance, especially in high-throughput environments. Monitor your Redis instance after enabling this feature.

  * Configure notifications for specific event types if full coverage isn't needed.
  * Monitor memory usage and CPU utilization.
  * Consider using a dedicated Redis instance for CDC if performance becomes an issue.
</Info>

You can enable keyspace notifications via:

<CodeGroup>
  ```bash Redis CLI theme={null}
  # Enable keyspace notifications via redis-cli
  redis-cli CONFIG SET notify-keyspace-events KEA

  # Verify the configuration
  redis-cli CONFIG GET notify-keyspace-events
  ```

  ```conf Redis Configuration File theme={null}
  # Add to redis.conf
  notify-keyspace-events KEA
  ```
</CodeGroup>

<Warning>
  **Configuration persistence**

  When using `CONFIG SET`, changes are not persisted across Redis restarts unless you also run `CONFIG REWRITE` or update the `redis.conf` file directly.
</Warning>

### 3. Create Database User

It's recommended to create a separate user for the Connector to access your Redis instance. Below is an example that creates a user with appropriate permissions.

<CodeGroup>
  ```bash Redis CLI theme={null}
  # Create a user for Streamkap (Redis 6.0+)
  # Replace {password} with a strong password
  ACL SETUSER streamkap_user on >{password} ~* +@read +@connection +config|get

  # Verify the user was created
  ACL LIST
  ```
</CodeGroup>

The ACL configuration above grants:

* `on`: Activates the user
* `>{password}`: Sets the password
* `~*`: Allows access to all keys
* `+@read`: Allows all read commands
* `+@connection`: Allows connection-related commands
* `+config|get`: Allows CONFIG GET command for verification

<Info>
  **Redis ACL compatibility**

  ACL support requires Redis 6.0 or higher. For earlier versions, you can use the `requirepass` setting in `redis.conf` for password authentication, though this provides less granular access control.
</Info>

### 4. Connection Details

You'll need the following information for the Streamkap Setup:

* **Hostname/IP**: The Redis server hostname or IP address
* **Port**: Default is `6379`
* **Database**: Redis database number (0-15 by default)
* **Username**: The username created above (if using ACL)
* **Password**: The password for the user

<Info>
  **TLS/SSL Connections**

  If your Redis instance requires TLS/SSL, ensure you have:

  * Valid certificates
  * The correct hostname that matches the certificate
  * TLS enabled on your Redis instance
</Info>

***

## Streamkap Setup

Follow these steps to configure your new connector:

### 1. Create the Source

* Navigate to [Add Connectors](https://app.streamkap.com/connectors/add?tab=Sources).
* Choose **Redis**.

### 2. Connection Settings

* **Name**: Enter a name for your connector.

* **Redis Type**: Choose the type of Redis deployment:
  * **Standalone**: Single Redis instance
  * **Cluster**: Redis Cluster deployment

* **Hostname**: Specify the hostname or IP address of your Redis server.

* **Port**: Default is `6379`.

* **Database**: Specify the Redis database number to stream data from (0-15 by default).

* **Connect via SSH Tunnel**: The Connector will connect to an SSH server in your network which has access to your Redis instance. This is necessary if the Connector cannot connect directly to your database.
  * See [SSH Tunnel](/ssh-tunnel) for setup instructions.

* **Username**: Username to access Redis. By default, Streamkap scripts use `streamkap_user`.
  * Leave empty for Redis versions \< 6.0 without ACL support.

* **Password**: Password to access the Redis instance.

* **Enable TLS?**: Whether to use an encrypted TLS/SSL connection to the Redis server.

* **Allow Insecure Connections?**: Allow connections with invalid or self-signed certificates (not recommended for production).

### 3. Advanced Parameters

* **Batch Size**: Number of keys to process in a single batch. Default is `1000`.
  * Adjust based on your Redis instance's performance and network capacity.

* **Poll Interval (ms)**: How frequently to poll Redis for changes. Default is `100`.
  * Lower values provide near real-time CDC but increase load on Redis.

Click **Save**.

## Data Capture

The Redis Source Connector captures changes to Redis keys and publishes them to Kafka topics. Each change event includes:

* **Key**: The Redis key that changed
* **Operation**: The type of operation (set, delete, expire, etc.)
* **Value**: The current value (for set operations)
* **Timestamp**: When the change occurred

### Topic Naming

By default, topics are named based on the Redis database:

* Pattern: `redis_db_{database_number}`
* Example: `redis_db_0` for database 0

### Supported Redis Data Types

The connector supports the following Redis data types:

* **String**: Simple key-value pairs
* **Hash**: Hash maps
* **List**: Ordered lists
* **Set**: Unordered sets
* **Sorted Set**: Ordered sets with scores
* **Stream**: Redis Streams (if using Stream Source mode)

## Troubleshooting

<AccordionGroup>
  <Accordion title="No events are being captured">
    Verify that keyspace notifications are enabled:<br /><br />

    ```bash theme={null}
    redis-cli CONFIG GET notify-keyspace-events
    ```

    The response should include `KEA` or the specific event types you need. If not, enable them as described in [Enable Keyspace Notifications](/redis-source-generic#2-enable-keyspace-notifications).
  </Accordion>

  <Accordion title="Authentication failures">
    If you're experiencing authentication issues:<br /><br />

    * Verify the username and password are correct
    * For Redis 6.0+, ensure the user has appropriate ACL permissions
    * Check if `requirepass` is set in redis.conf for Redis versions \< 6.0
    * Verify network connectivity and firewall rules
  </Accordion>

  <Accordion title="Performance impact on Redis">
    If Redis performance degrades after enabling CDC:<br /><br />

    * Reduce the batch size to lower per-batch load
    * Increase the poll interval to reduce polling frequency
    * Monitor Redis metrics (CPU, memory, network I/O)
    * Consider using a dedicated Redis replica for CDC
    * Limit keyspace notifications to specific event types instead of using `KEA`
  </Accordion>

  <Accordion title="Missing change events">
    If you're not capturing all expected changes:<br /><br />

    * Verify keyspace notifications include all necessary event types
    * Check that the connector is running and connected
    * Review connector logs for errors or warnings
    * Ensure the Redis user has permissions to read all keys
    * Verify the database number is correct in the configuration
  </Accordion>
</AccordionGroup>
