bench setup redis command generates Redis configuration files for both cache and queue services used by Frappe.
Usage
common_site_config.json.
What It Does
Read Configuration
Reads Redis port settings from
sites/common_site_config.json:redis_cache: Port for cache server (default: 13000)redis_queue: Port for queue server (default: 11000)
Generate redis_queue.conf
Creates
config/redis_queue.conf for the queue server.Used for background job processing via RQ (Redis Queue).Generate redis_cache.conf
Creates
config/redis_cache.conf for the cache server.Includes memory limits based on system RAM (5% by default, minimum 50MB).Generated Files
File Locations
Configuration Details
redis_cache.conf includes:- Port configuration
- Memory limits (
maxmemory) - Eviction policy (LRU)
- RDB persistence disabled
- AOF persistence settings
- Port configuration
- Persistence settings
- Save intervals for data durability
- Background save settings
Examples
Basic Setup
Generate Redis configuration:After Changing Ports
If you modify Redis ports incommon_site_config.json, regenerate the config:
Custom Cache Memory
Set custom maximum memory for Redis cache:Technical Details
Memory Calculation
The cache memory limit is automatically calculated as:- Uses 5% of total system RAM
- Minimum of 50 MB
- Can be overridden with
cache_maxmemoryin config
Redis Version Detection
The command detects your Redis version:Port Configuration
Default ports if not specified:| Service | Default Port | Config Key |
|---|---|---|
| Cache | 13000 | redis_cache |
| Queue | 11000 | redis_queue |
| SocketIO | Same as cache | redis_socketio |
When to Use
Initial Setup
This command is automatically run duringbench init. You typically don’t need to run it manually.
After Port Changes
Regenerate configuration after changing Redis ports in your config.Multi-Bench Setup
When running multiple benches on the same server, ensure each bench uses unique Redis ports:Troubleshooting
Redis Connection Errors
If you see “Could not connect to Redis”:Port Conflicts
If Redis fails to start due to port conflicts:-
Check what’s using the port:
-
Change the port in
common_site_config.json -
Regenerate configuration:
Related Commands
bench setup config- Generate common_site_config.jsonbench restart- Restart all bench services
Source Code
Implementation:bench/config/redis.py:10