Skip to main content

Redis Quick Start (5 Minutes)

Get Redis storage up and running with NeuroLink in under 5 minutes.

Prerequisites

  • Docker installed OR Redis installed locally
  • NeuroLink SDK installed (pnpm add @juspay/neurolink)

The fastest way to get Redis running for development and testing.

Start Redis Container

# Start Redis with persistence
docker run -d \
--name neurolink-redis \
-p 6379:6379 \
-v redis-data:/data \
redis:7-alpine

# Verify Redis is running
docker ps | grep neurolink-redis

Test Connection

# Test Redis connectivity
docker exec -it neurolink-redis redis-cli ping
# Expected output: PONG

Option 2: Local Install

macOS

# Install Redis with Homebrew
brew install redis

# Start Redis service
brew services start redis

# Verify installation
redis-cli ping
# Expected output: PONG

Ubuntu/Debian

# Install Redis
sudo apt update
sudo apt install redis-server -y

# Start Redis service
sudo systemctl start redis-server
sudo systemctl enable redis-server

# Verify installation
redis-cli ping
# Expected output: PONG

Windows (WSL2)

# Update packages
sudo apt update

# Install Redis
sudo apt install redis-server -y

# Start Redis
sudo service redis-server start

# Test connection
redis-cli ping
# Expected output: PONG

1. Set Environment Variables

# Add to your .env file
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD= # Leave empty for local dev
REDIS_DB=0
import { NeuroLink } from "@juspay/neurolink";

const neurolink = new NeuroLink({
conversationMemory: {
enabled: true,
store: "redis",
redisConfig: {
host: "localhost",
port: 6379,
db: 0,
},
},
});

// Use neurolink as normal
const result = await neurolink.generate({
input: { text: "Hello! How are you?" },
provider: "openai",
});

console.log(result.content);

3. Verify Storage

// Check conversation persistence
const stats = await neurolink.conversationMemory?.getStats();
console.log(stats); // { totalSessions: 1, totalTurns: 1 }

Quick Verification

Test Data Persistence

# In your Node.js console
const neurolink = new NeuroLink({
conversationMemory: {
enabled: true,
store: "redis",
redisConfig: { host: "localhost", port: 6379 }
}
});

// Generate a conversation
await neurolink.generate({
input: { text: "Remember this: my favorite color is blue" },
sessionId: "test-session",
userId: "test-user",
});

// Stop your app, restart, and verify data persists
const history = await neurolink.conversationMemory?.getUserSessionHistory(
"test-user",
"test-session"
);

console.log(history); // Should show your conversation

Check Redis Data

# Connect to Redis CLI
docker exec -it neurolink-redis redis-cli
# OR (local install)
redis-cli

# List all keys
127.0.0.1:6379> KEYS *
# Expected: Shows NeuroLink conversation keys

# Check a specific session
127.0.0.1:6379> GET neurolink:conversation:test-user:test-session
# Shows conversation data in JSON format

Common Issues

Connection Refused

Problem: Cannot connect to Redis

# Check if Redis is running
docker ps | grep neurolink-redis
# OR
sudo systemctl status redis-server

# Restart if needed
docker restart neurolink-redis
# OR
sudo systemctl restart redis-server

Port Already in Use

Problem: Port 6379 is already taken

# Use a different port for Redis
docker run -d --name neurolink-redis -p 6380:6379 redis:7-alpine

# Update NeuroLink config
redisConfig: { host: "localhost", port: 6380 }

Permission Denied

Problem: Cannot access Redis socket (Linux)

# Add your user to the redis group
sudo usermod -a -G redis $USER

# Restart Redis
sudo systemctl restart redis-server

Next Steps

Production Checklist

Before going to production, review:

  • Security: Set requirepass in Redis configuration
  • Persistence: Enable AOF (Append-Only File) for data durability
  • Monitoring: Set up health checks and alerts
  • Backup: Configure automated backup schedule
  • Performance: Tune maxmemory and eviction policies

See the Complete Redis Configuration Guide for production best practices.


Need Help? Check our Troubleshooting Guide or open an issue on GitHub.