Redis
Purpose
This page documents how Redis is used in Maqsafy for caching, sessions, queues, and background job processing.
Redis Responsibilities
| Usage | Description |
|---|---|
| Cache | Stores temporary frequently accessed data |
| Queue | Stores and processes queued jobs |
| Sessions | May store user session data depending on configuration |
| Rate Limiting | May support request throttling and login protection |
| Locks | May support distributed locks for critical operations |
Recommended Usage
Redis is recommended for production queue processing and caching because it provides better performance than a database-backed queue for high-volume background jobs.
Environment Variables
Use placeholders only.
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
Docker Example
If Redis runs in Docker, confirm the container is running:
docker ps
View logs:
docker logs <redis-container>
Inspect Docker networks:
docker network ls
docker network inspect <network-name>
Laravel Checks
Common Laravel commands:
php artisan cache:clear
php artisan queue:restart
php artisan queue:failed
Common Issues
Redis Hostname Error
Example symptom:
php_network_getaddresses: getaddrinfo for redis failed
Possible causes:
- Wrong Redis hostname in
.env - Redis container is not running
- Application container and Redis container are not on the same Docker network
- Docker service name changed
Redis Connection Refused
Possible causes:
- Redis service is down
- Wrong Redis port
- Firewall or network issue
- Redis requires authentication but password is missing
Troubleshooting Commands
docker ps
docker logs <redis-container>
docker network ls
docker network inspect <network-name>
If Redis CLI is available:
redis-cli -h <redis-host> -p 6379 ping
Expected response:
PONG
Operational Rules
- Redis must be monitored in production.
- Queue workers must be restarted after deployment when needed.
- Redis memory usage should be monitored.
- Redis should not be used as the only storage for permanent financial records.
- Financial records must remain in the database or ledger system.
Security Rules
- Do not expose Redis publicly.
- Do not document real Redis passwords.
- Do not place Redis credentials in screenshots.
- Restrict Redis access to internal services only.
- Use placeholders for hostnames and credentials.