Appearance
Redis Commands
Redis is the in-memory cache and queue server used by Zal Ultra for caching, sessions, and background job processing.
🟠 MEDIUM RISK
Restarting Redis will clear all cached data and may cause temporary slowdowns. Queue jobs will resume after restart.
Table of Contents
Service Management
Check Redis Status
bash
sudo systemctl status redis-serverStart Redis
bash
sudo systemctl start redis-serverStop Redis
🟠 CACHE LOSS
Stopping Redis will clear all cached data and interrupt queue processing.
bash
sudo systemctl stop redis-serverRestart Redis
🟠 CACHE CLEARED
Restart clears all cached data. Application will rebuild cache on demand.
bash
sudo systemctl restart redis-serverEnable on Boot
bash
sudo systemctl enable redis-serverRedis CLI
Connect to Redis
bash
redis-cliPing Redis (Test Connection)
bash
redis-cli ping
# Expected: PONGCheck Redis Info
bash
redis-cli infoCheck Specific Section
bash
redis-cli info memory
redis-cli info clients
redis-cli info statsCache Management
View All Keys (Use with Caution)
🟠 PERFORMANCE IMPACT
On large databases, KEYS * can block Redis. Use SCAN instead in production.
bash
redis-cli KEYS "*"Count All Keys
bash
redis-cli DBSIZESearch Keys by Pattern
bash
redis-cli KEYS "laravel_cache:*"
redis-cli KEYS "laravel_database_*"Get Key Value
bash
redis-cli GET "key_name"Delete Specific Key
bash
redis-cli DEL "key_name"Delete Keys by Pattern
🟠 DATA DELETION
This permanently deletes matching keys.
bash
redis-cli KEYS "laravel_cache:*" | xargs redis-cli DELClear All Cache (FLUSHDB)
🔴 CLEARS ALL DATA
This removes ALL data from the current database.
bash
redis-cli FLUSHDBClear All Databases (FLUSHALL)
🔴 CLEARS EVERYTHING
This removes ALL data from ALL Redis databases.
bash
redis-cli FLUSHALLClear Laravel Cache via Artisan
bash
# Preferred method - clears only Laravel cache
cd /var/www/html
php artisan cache:clearQueue Monitoring
Check Queue Length
bash
redis-cli LLEN "queues:default"
redis-cli LLEN "queues:sms"
redis-cli LLEN "queues:high"View Queue Contents
bash
redis-cli LRANGE "queues:default" 0 10Check Failed Jobs Queue
bash
redis-cli LLEN "queues:failed"Monitor Redis in Real-time
bash
redis-cli MONITORPress Ctrl+C to stop.
Memory Management
Check Memory Usage
bash
redis-cli INFO memoryKey Memory Stats
bash
redis-cli INFO memory | grep -E "used_memory_human|maxmemory_human|mem_fragmentation"Check Memory for Specific Key
bash
redis-cli MEMORY USAGE "key_name"Find Largest Keys
bash
redis-cli --bigkeysSet Memory Limit
bash
# In redis.conf or via CLI
redis-cli CONFIG SET maxmemory 512mb
redis-cli CONFIG SET maxmemory-policy allkeys-lruCheck Current Memory Policy
bash
redis-cli CONFIG GET maxmemory
redis-cli CONFIG GET maxmemory-policyTroubleshooting
Common Issues
Redis Won't Start
bash
# Check error log
sudo tail -100 /var/log/redis/redis-server.log
# Check permissions
sudo chown -R redis:redis /var/lib/redisConnection Refused
bash
# Check if Redis is running
sudo systemctl status redis-server
# Check if listening
sudo netstat -tlnp | grep 6379
# Check bind address in config
sudo grep "bind" /etc/redis/redis.confMemory Full
bash
# Check memory usage
redis-cli INFO memory
# Clear old cache
redis-cli FLUSHDB
# Or set memory limit with eviction
redis-cli CONFIG SET maxmemory 1gb
redis-cli CONFIG SET maxmemory-policy allkeys-lruSlow Performance
bash
# Check slow log
redis-cli SLOWLOG GET 10
# Check connected clients
redis-cli CLIENT LIST | wc -lConfiguration File
bash
sudo nano /etc/redis/redis.confImportant Settings
conf
# Memory limit
maxmemory 1gb
# Eviction policy
maxmemory-policy allkeys-lru
# Persistence (disable for pure cache)
save ""
appendonly no
# Bind address (localhost only for security)
bind 127.0.0.1After config changes:
bash
sudo systemctl restart redis-serverCheck Redis Version
bash
redis-server --version
redis-cli --versionQuick Reference Card
| Action | Command |
|---|---|
| Check status | sudo systemctl status redis-server |
| Start | sudo systemctl start redis-server |
| Stop | sudo systemctl stop redis-server |
| Restart | sudo systemctl restart redis-server |
| Connect CLI | redis-cli |
| Ping test | redis-cli ping |
| Memory info | redis-cli INFO memory |
| Key count | redis-cli DBSIZE |
| Clear cache | redis-cli FLUSHDB |
| Queue length | redis-cli LLEN "queues:default" |
| Monitor | redis-cli MONITOR |
| Config file | /etc/redis/redis.conf |
| Log file | /var/log/redis/redis-server.log |
