# Redis

UI Bakery allows you to easily connect to a Redis database with no need for additional layers like APIs or third-party services.

## Configuration

### Prerequisites

If your database is hosted behind a Firewall, you need to add our [IP addresses](https://docs.uibakery.io/concepts/data-sources#whitelisting-ip-addresses) to the Firewall whitelist.

### Connecting the data source

1. On the **Data sources** page, click **Connect**, and select *Redis* in the Data sources list.
2. Specify the required credentials:
   1. **Host**
   2. **Port**
   3. **Password** (if your Redis instance is in the [protected mode](https://redis.io/docs/latest/operate/oss_and_stack/management/security/))
   4. **Database number**
3. Click **Test connection** to check whether the connection can be established, and then click **Connect Datasource** to complete the setup.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FFWwgOlxhWP4jj6LOuoh5%2FCleanShot%202025-04-24%20at%2014.46.43%402x-min.png?alt=media&#x26;token=630d0332-4297-43c5-b193-b59e5a0184da" alt=""><figcaption></figcaption></figure>

## Usage

Once you have established the connection between UI Bakery and Redis, you can manage its data. \
UI Bakery allows executing most of the [Redis Commands](https://redis.io/commands/). \
A command should be sent as an **array** where the first element is a string representing *Redis Command type*, and the other elements of an array are *command arguments*, for example:

```javascript
['GET', 'key']
```

* It is also possible to send multiple commands at once as an *array of arrays*:

```javascript
[ ['GET', 'key1'], ['GET', 'key2'] ]
```

* UI Bakery also converts all input non-string command arguments to strings except for the `undefined` and `null` values - they are converted to empty strings. \
  \
  For example, if you execute `['SET', 'number', 42]` followed by `['GET', 'number']`, the result string will be `"42"`. \
  If you want to convert the value back to a number, you should use `Number({{data}})` in the result mapper.

For more Redis Command examples, check out [this page](https://docs.uibakery.io/reference/working-with-actions/redis-command).


---

# 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://docs.uibakery.io/reference/data-sources/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.
