> For the complete documentation index, see [llms.txt](https://docs.onum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.onum.com/pipelines/actions/advanced/redis.md).

# Redis

{% hint style="info" %}
See the changelog of this Action type [here](/actions-changelog/redis.md).
{% endhint %}

## Overview

[Redis](https://redis.io/) is a powerful in-memory data structure store that can be used as a database, cache, and message broker. It provides high performance, scalability, and versatility, making it a popular choice for real-time applications and data processing.

The **Redis** Action allows users to set and retrieve data from a Redis server.

{% hint style="warning" %}
In order to configure this action, you must first link it to a Listener. Go to [Building a Pipeline ](/pipelines/building-a-pipeline.md)to learn how to link.
{% endhint %}

## Ports <a href="#ports" id="ports"></a>

These are the input and output ports of this Action:

<details>

<summary>Input ports</summary>

* **Default port** - All the events to be processed by this Action enter through this port.

</details>

<details>

<summary>Output ports</summary>

* **Default port** - Events are sent through this port if no error occurs while processing them.
* **Error port** - Events are sent through this port if an error occurs while processing them.

</details>

## Installing Redis

To use this Action, you must install Redis and Redis CLI.

As installing Redis via a Docker is generally preferable, we will brief you on this procedure. To install it locally, check [this article](https://redis.io/docs/latest/operate/oss_and_stack/install/).

{% stepper %}
{% step %}
Start your local Redis Docker instance:

{% tabs %}
{% tab title="Using docker file" %}

```docker
FROM redis:latest

EXPOSE 6379

CMD ["redis-server"]

## build

docker build -t my-redis-image

## run

docker run -d --name my-redis my-redis-image
```

{% endtab %}

{% tab title="Using one line command" %}

```
docker run -d --name my-redis -p 6379:6379 redis/redis-stack-server:latest
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}
Now, connect to the Redis container:

```docker
docker exec -it {{ContainerID}} sh

> redis-cli
```

{% endstep %}

{% step %}
Use this command to get the IP:

```docker
# Read Value

127.0.0.1:6379> GET key

# Set Value

SET key value
```

{% endstep %}

{% step %}
Paste this IP in the **Redis endpoint** field of your **Redis** Action.
{% endstep %}
{% endstepper %}

For more help and in-depth detail, see [these use cases](https://www.simplehomelab.com/redis-docker-compose-example/).

## Configuration

{% stepper %}
{% step %}
Find **Redis** in the **Actions** tab (under the **Advanced** group) and drag it onto the canvas. Link it to the required [Listener](https://docs.onum.com/the-workspace/listeners) and [Data sink](https://docs.onum.com/the-workspace/pipelines/data-sinks).
{% endstep %}

{% step %}
To open the configuration, click the Action in the canvas and select **Configuration**.
{% endstep %}

{% step %}
Enter the required parameters:

**Connection Settings**

<table><thead><tr><th width="170.3984375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Endpoint</strong><mark style="color:red;"><strong>*</strong></mark></td><td>Enter the endpoint used to establish the connection to the Redis server.</td></tr></tbody></table>

**Network Timeout**

<table><thead><tr><th width="170.3984375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Read Timeout</strong></td><td>Enter the maximum amount of milliseconds to wait to receive data after the connection has been established and the request has been sent.</td></tr><tr><td><strong>Write Timeout</strong></td><td>Enter the maximum amount of milliseconds to wait while trying to send data to the server.</td></tr></tbody></table>

**Command**

<table><thead><tr><th width="170.3984375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Commands</strong></td><td><p>The command to read or write data from the Redis server. </p><ul><li><p><strong>SET</strong> </p><ul><li><strong>Redis Key</strong> - Choose the input field that contains it the model version.</li><li><strong>Value</strong> - Choose the field that contains the events you want to input to Redis.</li><li><strong>Expiration in seconds</strong> - Optionally, enter how long the key will be available in the Redis server.  The minimum value is <code>0</code>.</li></ul></li><li><p><strong>HSET</strong></p><ul><li><strong>Redis Key</strong> - Choose the input field that contains it the model version.</li><li><strong>Field/Value pairs -</strong> Add as many fields and pipeline values as required.</li></ul></li><li><p><strong>GET</strong></p><ul><li><strong>Redis Key</strong> - Choose the input field that contains it the model version.</li><li><strong>Output field</strong> - Enter a name for the output field that will store the output data.</li></ul></li><li><p><strong>HGET</strong> </p><ul><li><strong>Redis Key</strong> - Choose the input field that contains it the model version.</li><li><strong>Redis field</strong> - Select the field from the Listener or Action that serves as the HGET field. </li><li><strong>Output field</strong> - Enter a name for the output field that will store the output data.</li></ul></li></ul></td></tr></tbody></table>
{% endstep %}

{% step %}
Click **Save** to complete.
{% endstep %}
{% endstepper %}
