4 min read

redis.connector Documentation

Purpose

The redis.connector logic serves as an adapter that connects to a Redis database for executing commands. By simplifying the integration process with Redis, this component allows users to perform various operations such as data retrieval or modification directly through the Vantage analytics and data platform, making it an essential tool for businesses reliant on real-time data processing.

Settings

The redis.connector accepts the following settings:

1. inputs.command

2. inputs.args

3. session.user.clientId

How It Works

  1. Session Validation: The redis.connector first validates the user's session to ensure the user is logged in. If not, an error message is displayed requesting the user to log in.

  2. Command Verification: The connector checks whether the required inputs.command is provided. If missing, it throws an error.

  3. Service Lookup: Using the clientId, the connector retrieves the Redis service details from the database. If no service is found, it returns a message indicating that no Redis service exists for the client.

  4. Credential Retrieval: The connector fetches the necessary credentials for accessing the Redis service. If no credentials are found, it returns an error message.

  5. Command Execution: Upon successfully obtaining the Redis service and credentials, the connector initializes the integration using the required credentials. It then executes the specified Redis command, along with any provided arguments.

  6. Error Handling: If any errors occur during the execution (e.g., malformed command, connection issues), an error message is displayed with specific details regarding the failure.

Data Expectations

The redis.connector expects a well-defined set of data in the following format:

Use Cases & Examples

Use Cases

  1. Real-time Data Caching: A business using Redis for real-time data caching may need to refresh cache contents frequently based on user interactions. The redis.connector can be employed to issue commands dynamically based on user inputs or application state.

  2. Data Analytics: Analytics platforms may need to read from or manipulate cached datasets in Redis for reporting or analytical purposes. The redis.connector allows configuration of commands that can support such data manipulations efficiently.

  3. Session Management: An application leveraging Redis for session management can utilize the redis.connector to modify session states (like expiration) or retrieve user session data quickly.

Example Configuration

Use Case Example: Real-time Data Caching

Scenario: A web application, OrderTracker, needs to update the order status in Redis whenever an order is placed.

Configuration:

javascript
const redisCommandConfig = {
  inputs: {
    command: 'SET', // Command to execute
    args: ['order:12345', 'delivered'], // Setting order ID with its new status as 'delivered'
  },
};

Implementation: In the component, you could integrate the redis.connector as follows:

javascript
const response = await redisConnector(redisCommandConfig);
console.log(response.output1); // Confirm the command execution or catch potential errors

In this example, upon execution, the redis.connector would update the order status for order ID 12345 in the Redis database to delivered, enabling real-time updates for users tracking their orders.