How to use Redis as a Datasource on Appsmith
Integrating the Redis datasource into Appsmith
To connect your Redis Database instance to Appsmith as a datasources
Open Applications Page, select the application to want to configure and click on Edit.
On the navigation panel to the left side, Click on + next to Datasources Tab.
(Optional) Now click on + Create New, if you already have connected a Datasource previously.
Under Databases, Select Redis
Enter a name to your Redis datasource (e.g. My Redis Database)
Enter your Redis Database configurations inside the Connection section.
- Enter "0" as Database Number, if you are connecting to the database for the first time.
Enter your username and password to your Redis Database under Authentication section.
Once done, click on Save and then click on Test.
If the Pop up notifies you that My Redis Database datasource is valid, that means your Redis Database's configuration is correct and is to ready to connect to your Appsmith Application. If it Pop up notifies you about any other error, please check your Redis configuration.
Refer to Redis Datasource documentation for more information.
Using Redis as a Datasource
Lets create some keys in your Redis Database.
- After you have added your Datasource, click on New Query +.
Edit your Query name, from Query1 to CreatingKeys
From the Query field, create some keys (Enter one by one).
SET DEVELOPER "me"
SET ENV "DEV"
SET DATE "Thursday, 7 October, 2021"
- Done. We successfully created some keys.
To fetch keys from Redis Database, lets run queries.
Again create a new query, and name it as GetKeys
From the Query field, lets fetch our existing keys.
Response : me
Response : dev
Response : Thursday, 7 October, 2021
Once you fetch all keys successfully,then you are ready to proceed further.
Binding the data to a widget
- After running each query, select your desired Widget Type, and click to Add to canvas
- Now, change the widget name, and its attributes, according to your needs.
- Done, not that hard right?
Thats all, now you know how to use Redis as a data source for your Appsmith application.