You can now use IBM App Connect to build flows that integrate with Redis.

About 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?

  1. From your App Connect dashboard, click Catalog, and then from the Applications tab, click Redis.
  2. 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 0.
    • Allow certificate validation: Either true or 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.

    Connection fields for Redis

  3. 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.

  1. 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.

    Scheduler for Redis

  2. 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.
  3. Specify a key and value, and optionally configure an expiry timeout.

    Field selections for the Redis Update or create string action

  4. 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.)
    1. Add Slack as the next application and select Message > Create message as the action.
    2. Select the Slack channel that you want to monitor, and then map to the response from Redis.

      Slack for use case 1

      Here’s an example of the completed flow:

      redis flow

  5. Start the flow:
    start flow
  6. In the selected Slack channel, you’ll see a message with the details of the response payload from Redis.
    redis message

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.

    use case 2

    And then we’ll specify the hash key and field to retrieve.

    use case 2 properties

  • For the Slack action, we want to display the retrieved hash key/value pair in the Slack channel.
    use case2 slack response

When the flow runs, the Slack channel should show the response from the “Get hash field value” action.
response message

Join The Discussion

Your email address will not be published. Required fields are marked *