You can now use IBM App Connect to build flows that integrate with Redis.
Redis is an open source, in-memory data structure store that supports data structures such as strings, hashes, lists, sets, and sorted sets. You can use Redis as a simple or an advanced key/value store database. Redis has a cloud-hosted deployment model and is available as Databases for Redis and Compose For Redis on IBM Cloud, ElastiCache for Redis on Amazon, and Azure Cache for Redis on Microsoft Azure.
Note: App Connect supports IBM Redis V4.0 and Amazon Web Services (AWS) Redis V5.0, and uses the Redis node module, which uses socket-based commands to communicate with the Redis server.
Using Redis in App Connect
To use Redis in an App Connect flow, you’ll need to connect to your Redis server.
How do I connect?
- From your App Connect dashboard, click Catalog, and then from the Applications tab, click Redis.
- Click Connect and then enter the required connection details for connecting to your Redis account:
- Redis host name or IP address: The host name or IP address of the Redis server.
- Redis port number: The port number of the Redis server.
- Password: The password required for authentication.
- Database number: The database index number of the database to connect to. The default is
- Allow certificate validation: Either
false. If set to
true(the default), the certificate contents must be provided for validation.
- Certificate: If Allow certificate validation is set to
true, a certificate is mandatory. Specify the contents of the CA signed certificate in Base64 format.
- Click Connect again to add an account for your Redis server.
Sample use cases
We’ll use two simple use cases to demonstrate how Redis can be integrated with other apps in App Connect:
1. Use Redis as part of a flow to store a configuration in the form of key/value pairs.
2. Use Redis as part of a flow to retrieve previously stored configuration hash key/value pairs.
Use case 1: Creating a flow to store a configuration in key/value pairs
For this use case, we’ll create an event-driven flow that runs on a schedule to update or create a string in Redis and then display the response payload from Redis in a Slack channel as confirmation. Let’s assume that we’re already connected to both Redis and Slack.
- Select Scheduler as the event that will trigger the flow and then configure a schedule. For simplicity, we are using the default configuration and have also chosen to run the flow when it’s first switched on.
- Add Redis as the first application and select Strings > Update or create string as the action. We want to update an existing string in the Redis server or to create a string if the specified key doesn’t exist.
- Specify a key and value, and optionally configure an expiry timeout.
- Configure a dedicated Slack channel to receive the response from the Redis action. (We’ll assume that you’ve already created a Slack channel to monitor the response.)
- Add Slack as the next application and select Message > Create message as the action.
- Select the Slack channel that you want to monitor, and then map to the response from Redis.
Here’s an example of the completed flow:
- Start the flow:
- In the selected Slack channel, you’ll see a message with the details of the response payload from Redis.
Use case 2: Retrieving previously stored configuration hash key-value pairs
For this use case, we’ll create a similar flow to the one in use case 1, but with the following changes to the Redis and Slack actions:
- For the Redis action, we want to retrieve previously stored configuration hash key-value pairs from the Redis server, so we’ll add a Hashes > Get hash field value action.
And then we’ll specify the hash key and field to retrieve.
- For the Slack action, we want to display the retrieved hash key/value pair in the Slack channel.
When the flow runs, the Slack channel should show the response from the “Get hash field value” action.