This guide explains how to set up Redis for the Verus RPC server's caching functionality.
- Payment sessions are stored under keys
payments:{payment_id}(JSON-serialized sessions) - Revoked JWT IDs are stored under keys
jwt:revoked:{jti}with TTL - If Redis is unavailable, both stores fall back to in-memory, preserving functionality for a single instance
Windows:
# Using Chocolatey
choco install redis-64
# Or download from https://github.com/microsoftarchive/redis/releasesmacOS:
# Using Homebrew
brew install redisLinux (Ubuntu/Debian):
sudo apt update
sudo apt install redis-serverWindows:
redis-servermacOS/Linux:
# Start Redis service
sudo systemctl start redis-server
# Or start manually
redis-serverredis-cli ping
# Should return: PONGEdit Conf.toml:
[cache]
enabled = true
redis_url = "redis://127.0.0.1:6379"Edit Redis configuration file (redis.conf):
# Set a password
requirepass your_secure_password
# Optional: Set username (Redis 6.0+)
user default on >your_secure_password ~* &* +@all# Stop Redis
redis-cli shutdown
# Start with config
redis-server redis.confredis-cli
AUTH your_secure_password
pingEdit Conf.toml:
[cache]
enabled = true
redis_url = "redis://:your_secure_password@127.0.0.1:6379"redis-cli
ACL SETUSER cacheuser on >cache_password ~* &* +@all[cache]
enabled = true
redis_url = "redis://cacheuser:cache_password@127.0.0.1:6379"# Generate self-signed certificate
openssl req -x509 -newkey rsa:4096 -keyout redis.key -out redis.crt -days 365 -nodesEdit redis.conf:
tls-port 6380
tls-cert-file redis.crt
tls-key-file redis.key
tls-ca-cert-file redis.crt[cache]
enabled = true
redis_url = "rediss://127.0.0.1:6380"-
Check if Redis is running:
redis-cli ping
-
Check Redis port:
netstat -an | grep 6379 -
Check Redis logs:
tail -f /var/log/redis/redis-server.log
-
Verify password:
redis-cli AUTH your_password
-
Check Redis configuration:
redis-cli CONFIG GET requirepass
-
Check Redis memory usage:
redis-cli INFO memory
-
Configure memory limits in
redis.conf:maxmemory 100mb maxmemory-policy allkeys-lru
Edit redis.conf:
# Enable persistence
save 900 1
save 300 10
save 60 10000
# Memory optimization
maxmemory 100mb
maxmemory-policy allkeys-lru
# Network optimization
tcp-keepalive 300# Monitor Redis commands
redis-cli MONITOR
# Check cache statistics
redis-cli INFO stats- Use strong passwords
- Enable SSL/TLS in production
- Restrict network access
- Regular security updates
- Monitor access logs
# Run Redis with Docker
docker run -d --name redis-cache \
-p 6379:6379 \
-v redis-data:/data \
redis:7-alpine redis-server --requirepass your_passwordapiVersion: apps/v1
kind: Deployment
metadata:
name: redis-cache
spec:
replicas: 1
selector:
matchLabels:
app: redis-cache
template:
metadata:
labels:
app: redis-cache
spec:
containers:
- name: redis
image: redis:7-alpine
ports:
- containerPort: 6379
command: ["redis-server", "--requirepass", "your_password"][cache]
enabled = true
redis_url = "redis://127.0.0.1:6379"
default_ttl = 300
max_size = 104857600[cache]
enabled = true
redis_url = "redis://cacheuser:secure_password@redis.example.com:6379"
default_ttl = 600
max_size = 1073741824[cache]
enabled = true
redis_url = "rediss://cacheuser:secure_password@redis.example.com:6380"
default_ttl = 600
max_size = 1073741824If Redis is unavailable, the server will:
- Log a warning message
- Continue operating with in-memory cache only
- Provide helpful setup instructions
- Maintain full functionality
The in-memory cache provides basic caching functionality even without Redis, ensuring the server remains operational.