# Web3Proxy Redis Configuration

## Environment Variables

The Web3Proxy service now uses Redis for distributed idempotency storage across multiple instances.

### Required Environment Variables

- `REDIS_URL`: Redis connection string (default: `redis://localhost:6379`)
- `REDIS_PASSWORD`: Redis password (optional, for authenticated Redis instances)
- `LOG_LEVEL`: Logging level (default: `info`)

### Docker Configuration

When running in Docker, set the Redis URL to:
```
REDIS_URL=redis://redis:6379
```

For password-protected Redis instances:
```
REDIS_URL=redis://redis:6379
REDIS_PASSWORD=your_redis_password
```

### Production Configuration

For production deployments with password-protected Redis:

1. Set environment variables:
   ```bash
   export REDIS_URL=redis://your-redis-host:6379
   export REDIS_PASSWORD=your_secure_password
   ```

2. Or use a connection string with embedded password:
   ```
   REDIS_URL=redis://:your_password@your-redis-host:6379
   ```

### Fallback Behavior

If Redis is not available, the service will automatically fall back to in-memory storage with a warning message. This ensures the service continues to work even without Redis, but idempotency will only work within a single instance.

### Production Deployment

For production deployments with multiple Web3Proxy instances:

1. Ensure Redis is running and accessible
2. Set the `REDIS_URL` environment variable
3. Monitor Redis connection status in logs
4. Consider Redis clustering for high availability

### Idempotency Key Format

Idempotency keys are stored in Redis with the prefix `idempotency:` and have a TTL of 5 minutes.

Example Redis key: `idempotency:123e4567-e89b-12d3-a456-426614174000`
