Storage Backends
MilliCache works with any Redis-compatible server. This guide covers supported backends, configuration, and recommendations.
Supported Backends#
| Backend | License | Key Feature | Best For |
|---|---|---|---|
| Redis | RSALv2 | Most popular, proven | Most deployments |
| ValKey | BSD-3 | Open-source Redis fork | License-concerned users |
| KeyDB | BSD-3 | Multithreaded | High-throughput needs |
| Dragonfly | BSL | Memory efficient | Large cache requirements |
All backends use the same protocol and configuration. Your choice depends on licensing preferences, performance needs, and hosting availability.
Quick Comparison#
Redis#
The original in-memory data store. Most documentation, hosting support, and community resources.
- Pros: Battle-tested, extensive documentation, widest hosting support
- Cons: RSALv2 license may concern some users
- Install: redis.io/docs/install
ValKey#
Linux Foundation fork of Redis, fully open-source under BSD-3 license.
- Pros: Fully open-source, active development, drop-in Redis replacement
- Cons: Newer project, less hosting support currently
- Install: valkey.io/docs
KeyDB#
Multithreaded Redis fork with improved performance on multi-core systems.
- Pros: Higher throughput, MVCC for better concurrency
- Cons: Less widespread than Redis
- Install: docs.keydb.dev
Dragonfly#
Modern Redis alternative with significantly better memory efficiency.
- Pros: Uses less memory for same data, faster on large datasets
- Cons: Newer, Business Source License
- Install: dragonflydb.io/docs
MilliCache Configuration#
Connection settings are the same for all backends.
Basic Connection#
1// wp-config.php
2define( 'WP_CACHE', true );
3
4define( 'MC_STORAGE_HOST', '127.0.0.1' );
5define( 'MC_STORAGE_PORT', 6379 );
With Authentication#
1define( 'MC_STORAGE_HOST', 'redis.example.com' );
2define( 'MC_STORAGE_PORT', 6379 );
3define( 'MC_STORAGE_PASSWORD', 'your-password' );
Using Unix Socket#
1define( 'MC_STORAGE_HOST', '/var/run/redis/redis.sock' );
2define( 'MC_STORAGE_PORT', 0 ); // Ignored for sockets
With TLS (e.g. AWS ElastiCache)#
1define( 'MC_STORAGE_HOST', 'tls://master.example.cache.amazonaws.com' );
2define( 'MC_STORAGE_PORT', 6379 );
Multiple Sites on Same Server#
Use different databases or prefixes:
1// Site A
2define( 'MC_STORAGE_DB', 0 );
3define( 'MC_STORAGE_PREFIX', 'sitea' );
4
5// Site B
6define( 'MC_STORAGE_DB', 1 );
7define( 'MC_STORAGE_PREFIX', 'siteb' );
All Connection Constants#
| Constant | Default | Description |
|---|---|---|
MC_STORAGE_HOST |
127.0.0.1 |
Hostname, IP, socket, or tls://host |
MC_STORAGE_PORT |
6379 |
TCP port (0 for sockets) |
MC_STORAGE_PASSWORD |
'' |
AUTH password |
MC_STORAGE_DB |
0 |
Database number (0-15) |
MC_STORAGE_PERSISTENT |
true |
Use persistent connections |
MC_STORAGE_PREFIX |
mll |
Key prefix |
Recommended Server Configuration#
These settings are recommended for WordPress caching workloads:
1# Memory allocation (adjust based on your needs)
2maxmemory 256mb
3maxmemory-policy allkeys-lru
4
5# Persistence (optional - cache can be regenerated)
6save ""
7appendonly no
8
9# Performance
10tcp-keepalive 300
11timeout 0
12
13# Security (if exposed to network)
14bind 127.0.0.1
15requirepass your-strong-password
Memory Sizing#
| Site Size | Recommended Memory |
|---|---|
| Small (< 100 pages) | 64 MB |
| Medium (100-1000 pages) | 128-256 MB |
| Large (1000+ pages) | 512 MB+ |
The allkeys-lru eviction policy automatically removes least-recently-used entries when memory is full.
Testing Your Connection#
After configuration, verify the connection:
1# Quick test
2wp millicache test
3
4# Check status
5wp millicache status
6
7# View stats
8wp millicache stats
Troubleshooting Connection Issues#
Connection Refused#
Error: Connection refused
Causes:
- Server not running
- Wrong host/port
- Firewall blocking connection
Solutions:
1# Check if Redis is running
2redis-cli ping
3
4# Check listening port
5netstat -tlnp | grep 6379
6
7# Test connection manually
8redis-cli -h 127.0.0.1 -p 6379 ping
Authentication Failed#
Error: NOAUTH Authentication required
Solution: Set the password constant:
1define( 'MC_STORAGE_PASSWORD', 'your-password' );
Timeout#
Error: Connection timed out
Causes:
- Server overloaded
- Network issues
- Firewall timeout
Solutions:
- Check server resources
- Verify network connectivity
- Check firewall rules
Cloud Provider Options#
Most cloud providers offer managed Redis:
| Provider | Service |
|---|---|
| AWS | ElastiCache for Redis |
| Google Cloud | Memorystore |
| Azure | Azure Cache for Redis |
| DigitalOcean | Managed Redis |
| Upstash | Serverless Redis |
For managed services, use the provided connection details in your MilliCache configuration.
Performance Tips#
- Run locally when possible — Same-machine Redis has lowest latency
- Use persistent connections — Reduces connection overhead
- Enable compression —
MC_CACHE_GZIPreduces network transfer - Size memory appropriately — Avoid frequent evictions
- Monitor with
wp millicache stats— Track cache efficiency
Next Steps#
- Configuration Reference — All settings
- WP-CLI Commands — Command reference
- Troubleshooting — Common issues