# DIDI Cache Service 🚀 ## Super Simple Start Guide ⚡ ### Step 1: Set Your Password ```bash # Copy the example file cp .env.example .env # Edit .env and change this line: REDIS_PASSWORD=YOUR_SECURE_PASSWORD_HERE ``` ### Step 2: Start Redis ```bash docker compose up -d ``` That's it! Your cache is running! 🎉 ## Check If It's Working ✅ ```bash # See if container is healthy docker ps # Look for: didi-cache (healthy) ``` ## Connection Info 📡 - **Host**: localhost - **Port**: 6380 (not 6379 to avoid conflicts!) - **Password**: (what you set in .env) ## Test the Connection 🔌 ```bash # Connect with Redis CLI docker exec -it didi-cache redis-cli -a YOUR_PASSWORD # Test it 127.0.0.1:6379> PING PONG # Exit 127.0.0.1:6379> EXIT ``` ## What's Inside? 📦 This Redis cache is configured for: - ✅ 512MB memory (perfect for status & results) - ✅ Auto-expiry support (services set TTL) - ✅ Persistence enabled (survives restarts) - ✅ Password protected ### How DIDI Uses Redis 🔄 ``` Pipeline runs → Status stored here (24hr TTL) → Results cached here → UI polls for updates → After 24hrs, auto-deleted ``` ### Key Patterns We Store 📝 - `run:{run_id}` - Pipeline execution status - `node_status:{run_id}` - Each node's progress - `results:{run_id}` - Analysis results ## Common Commands 🛠️ ```bash # Stop cache docker compose down # View logs docker compose logs -f # Connect to Redis CLI docker exec -it didi-cache redis-cli -a YOUR_PASSWORD # Restart fresh (WARNING: Deletes all cache!) docker compose down -v docker compose up -d ``` ## Monitor Cache Usage 📊 ```bash # Check memory usage docker exec -it didi-cache redis-cli -a YOUR_PASSWORD INFO memory # See all keys docker exec -it didi-cache redis-cli -a YOUR_PASSWORD KEYS "*" # Count keys docker exec -it didi-cache redis-cli -a YOUR_PASSWORD DBSIZE ``` ## Troubleshooting 🔧 ### Port 6380 already in use? Edit `.env` and change `REDIS_PORT` to something else (like 6381) ### Can't connect? 1. Check container is healthy: `docker ps` 2. Verify password in .env 3. Make sure you're using port 6380, not 6379 ### Memory full? Redis will auto-delete least recently used keys (LRU policy) ## Part of Something Bigger 🏗️ This cache is part of the DIDI Backend data layer: ``` 📁 data-layer/ ├── 📁 didiDatabase/ (PostgreSQL - Done!) ├── 📁 didiCache/ (Redis - You are here!) ├── 📁 didiQueue/ (RabbitMQ - Next) └── 📁 didiStorage/ (MinIO - Coming soon) ``` ## Quick Health Check 🏥 ```bash # Is it running? docker exec -it didi-cache redis-cli -a YOUR_PASSWORD PING # Response should be: # PONG ``` ## Why Port 6380? 🤔 The old monolithic setup uses port 6379. We use 6380 to: - Avoid conflicts during migration - Run both services side-by-side - Easy rollback if needed --- **That's all you need to know! Happy caching! ⚡** *Version: 1.0.0 | Redis 7-alpine*