mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 06:41:08 +02:00
2.1 KiB
2.1 KiB
Redis Cache - Quick Start Guide
🚀 5-Minute Setup
macOS/Linux
# 1. Install Redis
brew install redis
# 2. Start Redis
brew services start redis
# 3. Add to .env.development
echo "REDIS_HOST=localhost" >> .env.development
echo "REDIS_PORT=6379" >> .env.development
echo "REDIS_PASSWORD=" >> .env.development
# 4. Start app
npm run dev
# 5. Verify
curl http://localhost:5173/api/redis-status
Windows (WSL2)
# 1. Install Redis in WSL2
sudo apt update
sudo apt install redis-server
# 2. Start Redis
sudo service redis-server start
# 3. Configure (same as macOS)
Docker
# 1. Run Redis container
docker run -d -p 6379:6379 --name uload-redis redis:alpine
# 2. Configure (same as above)
✅ Verify It's Working
Check Connection
# Should return: PONG
redis-cli ping
Check App Status
Visit: http://localhost:5173/api/redis-status
Should see:
{
"connected": true,
"available": true
}
Test Cache Performance
- Create a short link
- Visit it (slow - cache miss)
- Visit again (fast - cache hit!)
- Check console for "Cache HIT!" message
🛠 Common Commands
# View all cached links
redis-cli keys "redirect:*"
# Clear cache
redis-cli flushall
# Monitor activity
redis-cli monitor
# Stop Redis
brew services stop redis
🔥 Quick Tips
- No Password Locally: Leave REDIS_PASSWORD empty for local dev
- Auto-Fallback: App works without Redis (just slower)
- Hot Reload: Changes to Redis config need server restart
- Memory: Redis uses ~50MB for thousands of links
📚 Learn More
🆘 Help
Redis won't start?
brew services restart redis
Connection refused?
# Check if running
ps aux | grep redis
Cache not working?
- Check console for Redis connection message
- Verify environment variables are loaded
- Try explicit env vars:
REDIS_HOST=localhost npm run dev