2024-09-13 13:53:19 +00:00
---
id: redis
title: Redis
---
ToolJet enables you to execute Redis commands on your Redis instances.
2024-10-11 09:31:35 +00:00
< div style = {{paddingTop:'24px'}} >
2024-09-13 13:53:19 +00:00
## Connecting to Redis
2024-10-11 09:31:35 +00:00
To establish a connection with the Redis data source, you can either click on the ** + Add new Data source** button located on the query panel or navigate to the ** [Data Sources ](/docs/data-sources/overview )** page from the ToolJet dashboard and choose Redis as the data source.
2024-09-13 13:53:19 +00:00
2024-10-11 09:31:35 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/redis/connect-v2.png" alt = "Redis Connection" style = {{marginBottom:'15px'}} / >
2024-09-13 13:53:19 +00:00
2024-10-11 09:31:35 +00:00
To connect ToolJet with Redis, you need to provide the following connection details:
2024-09-13 13:53:19 +00:00
- **Host**: The address or hostname of the Redis server.
- **Port**: The port number used by the Redis server (default is 6379).
- **Username**: The username used for authentication.
- **Password**: The password used for authentication.
- **TLS**: Toggle to enable/disable TLS connection.
- **TLS Certificate**: Choose the type of TLS certificate (None, CA certificate, or Client certificate).
Depending on the TLS certificate option selected, you may need to provide additional information:
- For **CA certificate** :
- **CA Cert**: The CA certificate for TLS connection.
- For **Client certificate** :
- **CA Cert**: The CA certificate for TLS connection.
- **Client Key**: The client key for TLS connection.
- **Client Cert**: The client certificate for TLS connection.
2024-10-11 09:31:35 +00:00
< / div >
< div style = {{paddingTop:'24px'}} >
## Querying Redis
2024-09-13 13:53:19 +00:00
2024-10-11 09:31:35 +00:00
1. Click on ** + Add** button of the query manager at the bottom panel of the editor.
2. Select the **Redis** datasource added in previous step.
3. Enter the query.
4. Click on the **Preview** button to preview the output or Click on the **Run** button to trigger the query.
2024-09-13 13:53:19 +00:00
Here are some examples of Redis commands and their usage. You can refer to the [Redis Official Documentation ](https://redis.io/commands ) for a complete list of supported commands.
### PING Command
2024-10-11 09:31:35 +00:00
The `PING` command is used to test the connection to Redis. If the connection is successful, the Redis server will respond with **PONG** .
2024-09-13 13:53:19 +00:00
```shell
PING
```
2024-10-11 09:31:35 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/redis/ping.png" alt = "Redis Connection" style = {{marginBottom:'15px'}} / >
2024-09-13 13:53:19 +00:00
### SET Command
The `SET` command is used in Redis to assign a value to a specific key.
```shell
SET key value
```
2024-10-11 09:31:35 +00:00
#### Example
2024-09-13 13:53:19 +00:00
When the input value contains spaces, you should encode the value before providing it as an input:
```shell
SET products {{encodeURI('John Doe')}}
```
2024-10-11 09:31:35 +00:00
< img className = "screenshot-full" src = "/img/datasource-reference/redis/encode-v2.png" alt = "Redis Example Encode" style = {{marginBottom:'15px'}} / >
2024-09-13 13:53:19 +00:00
### GET Command
The `GET` command is used in Redis to retrieve the value associated with a specific key.
```shell
GET key
```
2024-10-11 09:31:35 +00:00
#### Example
2024-09-13 13:53:19 +00:00
To retrieve a value that was previously encoded while setting, you can use transformations.
2024-10-11 09:31:35 +00:00
1. Enter the GET command in the editor:
2024-09-13 13:53:19 +00:00
```shell
GET products
```
2024-10-11 09:31:35 +00:00
2. Enable Transformations (JS) and use `decodeURI` :
2024-09-13 13:53:19 +00:00
```js
return JSON.parse(decodeURI(data));
```
< div style = {{textAlign: ' center ' } } >
< img className = "screenshot-full" src = "/img/datasource-reference/redis/decode-v2.png" alt = "Redis Example Decode" / >
2024-10-11 09:31:35 +00:00
< / div >
< / div >