Setup Guide
This guide walks you through setting up a Redis server and obtaining the connection details required to use the Redis connector.
Prerequisites
- A running Redis server (v6.x or later recommended). You can download Redis or use a managed service such as Redis Cloud, Amazon ElastiCache, or Azure Cache for Redis.
Step 1: Install and start Redis
If you are running Redis locally:
-
Download and install Redis from redis.io/download.
-
Start the Redis server:
redis-server -
Verify the server is running by connecting with the CLI:
redis-cli pingYou should see
PONGin the response.
For macOS, you can install Redis with Homebrew: brew install redis && brew services start redis.
Step 2: Configure authentication (optional)
By default, Redis does not require authentication. To enable it:
-
Open the Redis configuration file (
redis.conf). -
Set a password using the
requirepassdirective:requirepass your_secure_password -
Optionally, configure an ACL user with specific permissions:
user myuser on >mypassword ~* +@all -
Restart the Redis server to apply the changes.
Always enable authentication for production deployments. An unprotected Redis server exposed to the internet is a serious security risk.
Step 3: Enable TLS/SSL (optional)
For encrypted connections:
-
Generate or obtain TLS certificates (CA cert, server cert, and server key).
-
Configure Redis with TLS in
redis.conf:tls-port 6380
tls-cert-file /path/to/redis.crt
tls-key-file /path/to/redis.key
tls-ca-cert-file /path/to/ca.crt -
Restart the Redis server.
When using TLS, connect to the configured tls-port (commonly 6380) instead of the standard port (6379).
If your Redis deployment requires StartTLS rather than a dedicated TLS port, set secureSocket.startTls: true in the Ballerina client configuration.
Step 4: (Optional) Set up a Redis cluster
To use the connector with a Redis cluster, run Redis in cluster mode. When configuring the Ballerina client, set isClusterConnection: true in ConnectionConfig and provide a single seed node. The connector will resolve the rest of the cluster topology from that node.
For a local cluster setup, see the in-repo docker compose file at tests/resources/docker/compose-cluster.yml.
Step 5: Note your connection details
Collect the following details for configuring the Ballerina client:
- Host: The Redis server hostname or IP address (default:
localhost). - Port: The Redis server port (default:
6379, or6380for TLS). - Password: The authentication password, if configured.
- Username: The ACL username, if using Redis ACLs (Redis 6.0+).
For managed Redis services, find these details in your cloud provider's console.
Many managed Redis services provide a single connection URI such as redis://user:password@host:port (or rediss://... for TLS) instead of separate fields. The connector accepts either form. See the Action Reference for both initialization patterns.