Skip to content

Redis

Redis can be utilized to enhance performance and scalability by serving as a caching layer to store frequently accessed data, reducing database load and response times. Additionally, Redis can be employed for session management, real-time analytics, and inter-service communication, making it a versatile tool for improving the efficiency and responsiveness.

Configuring Redis

Configuring Redis for Martini Server Runtime involves setting up Redis to enhance application performance and data management effectively. Begin by installing Redis on your server or using a managed Redis service. Proper configuration ensures that Redis integrates seamlessly with Martini, delivering fast and reliable data access and improving overall application efficiency. Here’s a straightforward guide to adding a new database connection:

Configuration Guide

Via API Explorer: Database connections can be configured using the Martini API Explorer, a user-friendly interface designed for efficient interaction with the system's APIs. Follow these steps to configure the database connections through the API Explorer:

  1. Access the API Explorer: Open a web browser and go to [HOST]:8080/api-explorer/ to access the API Explorer.

  2. Navigate to the Database Tag: Locate and click on the database tag within the API Explorer to view various database configuration and operation endpoints.

  3. Configure Connection Pool: Use the esbapi/databases endpoint found under the database tag to save a database connection pool.

  4. Use POST to Save a Connection Pool: Save the connection pool by using the POST method at the /esbapi/databases endpoint. Here is a minimum requirement for a JSON payload:

    1
    2
    3
    4
    5
     {
      "name": "[name]",
      "type": "redis",
      "url": "redis://<HOST>:6379/<DATABASE>"
     }
    

Via File System: Alternatively, database connections can be modified directly in the file system by editing the .dbxml file located in the //conf/db-pool/ directory. The .dbxml file refers to the specific file for your database configuration. This method is particularly useful in environments with restricted API access or during initial setup stages.

To modify database connections directly through the file system, follow these steps:

  1. Locate the Configuration File: Navigate to the /<martini-home>/conf/db-pool/ directory on your server and locate the <name>.dbxml file.

  2. Edit the Database Connections: Open the <name>.dbxml file in a text editor and modify the database connection properties.

  3. Save and Restart: After making the desired changes, save the file. It is essential to restart the Martini Runtime instance to apply the new settings. This ensures that all components of the application use the updated Redis configuration. Here is a minimum requirement for a dbXML:

    1
    2
    3
    4
    5
    <database>
      <name>[name]</name>
      <type>redis</type>
      <url>redis://[HOST]:6379/[DATABASE]</url>
    <database>
    

Configuring Redis in Martini Designer

  1. Navigate to the Navigator view and right-click on the Databases node of the instance where you intend to add the database connection.
  2. Choose New > Database Connection.
  3. Specify a name for the connection and select the database type Redis.
  4. Fill in the database connection details in the provided form.
  5. Save the changes.

Database Properties

The table below outlines the configurable properties for a database connection:

Field Name Parameters Required Default Value Description
Name name true null The name of the database connection.
Auto Start autoStart false true Whether the database connection should start automatically.
Type type true null The type of database (e.g., redis).
URI uri true null The URI for connecting to the Redis server.
Password password false (empty) Password for Redis server authentication.
Ping Before Activate Connection pingBeforeActivateConnection false false Whether to ping before activating the connection.
Auto Reconnect autoReconnect false true Automatically reconnect if the connection is lost.
Cancel Commands On Reconnect Failure cancelCommandsOnReconnectFailure false false Whether to cancel commands if reconnecting fails.
Publish On Scheduler publishOnScheduler false false Whether to publish messages on a scheduler.
Suspend Reconnect On Protocol Failure suspendReconnectOnProtocolFailure false false Whether to suspend reconnecting on protocol failure.
Request Queue Size requestQueueSize false 2147483647 The size of the request queue.
Disconnected Behavior disconnectedBehavior false DEFAULT Behavior when disconnected from Redis.
Socket Options socketOptions false null Configuration settings for socket connections.
Connect Timeout Millis connectTimeoutMillis false 10000 Timeout in milliseconds for connecting to Redis.
Keep Alive keepAlive false false Whether to keep the socket connection alive.
TCP false Delay tcpfalseDelay false false Whether to disable Nagle's algorithm for TCP connections.
SSL Options sslOptions false null SSL/TLS configuration options.
SSL Provider sslProvider false JDK Specifies the SSL provider.
Start TLS startTls false false Whether to start TLS/SSL after the connection is established.
Connection Options connectiofalseptions false null Additional options for managing the Redis connection.
Auto Flush Commands autoFlushCommands false true Whether to automatically flush commands after each operation.
Connection Timeout Millis connectionTimeoutMillis false -1 Timeout for establishing a connection. -1 indicates false timeout.
Connection Pool Options connectionPoolOptions false null Settings for the Redis connection pool.
Max Total maxTotal false 8 Maximum number of connections in the pool.
Max Idle maxIdle false 8 Maximum number of idle connections in the pool.
Min Idle minIdle false 0 Minimum number of idle connections in the pool.
LIFO lifo false true Whether the pool uses a Last In First Out (LIFO) order for connections.
Fairness fairness false false Whether to use fairness in connection pooling.
Max Wait Millis maxWaitMillis false 0 Maximum wait time in milliseconds for getting a connection from the pool.
Min Evictable Idle Time Millis minEvictableIdleTimeMillis false 1800000 Minimum time an idle connection must be in the pool before it is eligible for eviction.
Soft Min Evictable Idle Time Millis softMinEvictableIdleTimeMillis false -1 Soft minimum idle time for eviction. -1 indicates false soft minimum.
Num Tests Per Eviction Run numTestsPerEvictionRun false 3 Number of connections to test per eviction run.
Evictor Shutdown Timeout Millis evictorShutdownTimeoutMillis false 10000 Timeout in milliseconds for shutting down the evictor.
Test On Create testOnCreate false false Whether to test connections on creation.
Test On Borrow testOnBorrow false false Whether to test connections before borrowing from the pool.
Test On Return testOnReturn false false Whether to test connections before returning to the pool.
Test While Idle testWhileIdle false false Whether to test connections while they are idle.
Time Between Eviction Runs Millis timeBetweenEvictionRunsMillis false -1 Time in milliseconds between eviction runs. -1 indicates false periodic eviction.
Block When Exhausted blockWhenExhausted false true Whether to block when the pool is exhausted.
JMX Enabled jmxEnabled false false Whether to enable JMX (Java Management Extensions) for monitoring.