Storage Backends

MilliCache works with any Redis-compatible server. This guide covers supported backends, configuration, and recommendations.

Supported Backends#Copied!

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#Copied!

Redis#Copied!

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#Copied!

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#Copied!

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#Copied!

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#Copied!

Connection settings are the same for all backends.

Basic Connection#Copied!

 1// wp-config.php
 2define( 'WP_CACHE', true );
 3
 4define( 'MC_STORAGE_HOST', '127.0.0.1' );
 5define( 'MC_STORAGE_PORT', 6379 );

With Authentication#Copied!

 1define( 'MC_STORAGE_HOST', 'redis.example.com' );
 2define( 'MC_STORAGE_PORT', 6379 );
 3define( 'MC_STORAGE_USERNAME', 'your-username' );
 4define( 'MC_STORAGE_PASSWORD', 'your-password' );

Using Unix Socket#Copied!

 1define( 'MC_STORAGE_HOST', '/var/run/redis/redis.sock' );
 2define( 'MC_STORAGE_PORT', 0 );  // Ignored for sockets

With TLS (e.g. AWS ElastiCache)#Copied!

 1define( 'MC_STORAGE_HOST', 'tls://master.example.cache.amazonaws.com' );
 2define( 'MC_STORAGE_PORT', 6379 );

Multiple Sites on Same Server#Copied!

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#Copied!

Constant Default Description
MC_STORAGE_HOST 127.0.0.1 Hostname, IP, socket, tls://host, or a node array (see below)
MC_STORAGE_PORT 6379 TCP port (0 for sockets)
MC_STORAGE_USERNAME '' ACL username (default user if empty)
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
MC_STORAGE_TIMEOUT 1.0 Connection timeout in seconds
MC_STORAGE_READ_TIMEOUT 2.0 Read/write timeout in seconds

Timeouts#Copied!

MC_STORAGE_TIMEOUT (default 1.0) bounds connecting to the server, so an unreachable backend falls back to uncached WordPress quickly instead of stalling the request. MC_STORAGE_READ_TIMEOUT (default 2.0) bounds waiting for a command response; raise it only if you serve very large cached responses over a slow link.

High Availability: Replication & Sentinel#Copied!

For read-scaling, a node-local replica, or automatic failover, set MC_STORAGE_HOST to an array. A master key selects replication; a service key selects Sentinel. These modes are configured in wp-config.php only; the Settings screen shows a read-only notice when an array is active.

MC_STORAGE_USERNAME, MC_STORAGE_PASSWORD, and MC_STORAGE_DB apply to every node. Each address is host, host:port, or tls://host[:port].

Replication (master + replicas)#Copied!

 1define( 'MC_STORAGE_HOST', array(
 2    'master'   => 'master.example.com',                     // writes
 3    'replicas' => array( '127.0.0.1', 'replica.tld:6380' ), // reads
 4) );
 5
 6define( 'MC_STORAGE_PASSWORD', 'shared-secret' );  // applied to all nodes

replicas is optional and accepts a single address or a list. Replication is asynchronous, so a just-written entry may briefly lag on a replica.

Sentinel (managed failover)#Copied!

 1define( 'MC_STORAGE_HOST', array(
 2    'service'   => 'mymaster',
 3    'sentinels' => array( '10.0.0.1:26379', '10.0.0.2:26379' ),
 4) );

Sentinel discovers the master and re-resolves it on failover. Cluster mode (sharding across multiple masters) is not supported; if your project requires it, reach out.

A misconfigured array (both master and service, Sentinel without sentinels, or no recognized key) disables the cache and logs the reason rather than connecting to the wrong server.

MilliCache Pro adds a visual connection editor for all three topologies, so replication and Sentinel can be set up from the settings screen instead of a MC_STORAGE_HOST array in wp-config.php.

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#Copied!

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.

Applying Settings at Runtime#Copied!

You don't have to edit the Redis configuration file to change these. The memory limit and eviction policy can both be applied live with CONFIG SET, with no restart:

 1redis-cli CONFIG SET maxmemory 512mb
 2redis-cli CONFIG SET maxmemory-policy allkeys-lru

To target the exact server MilliCache is configured to use (host, port, database, and password) without looking those details up, open a session with wp millicache cli and run the commands there:

 1wp millicache cli
 2127.0.0.1:6379> CONFIG SET maxmemory 512mb
 3127.0.0.1:6379> CONFIG SET maxmemory-policy allkeys-lru
 4127.0.0.1:6379> quit

CONFIG SET takes effect immediately but is lost on the next Redis restart. To make the change permanent, either add the same directives to your Redis configuration file, or run CONFIG REWRITE to write the running configuration back to that file (this requires Redis to already be started from a config file):

 1redis-cli CONFIG REWRITE

Testing Your Connection#Copied!

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#Copied!

Connection Refused#Copied!

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#Copied!

Error: NOAUTH Authentication required

Solution: Set the authentication constants:

 1define( 'MC_STORAGE_USERNAME', 'your-username' );     // omit if using default user
 2define( 'MC_STORAGE_PASSWORD', 'your-password' );

Timeout#Copied!

Error: Connection timed out

Causes:

  • Server overloaded
  • Network issues
  • Firewall timeout

Solutions:

  • Check server resources
  • Verify network connectivity
  • Check firewall rules
  • If the backend is healthy but distant, raise MC_STORAGE_TIMEOUT (connection) or MC_STORAGE_READ_TIMEOUT (command response) above their 1.0/2.0 second defaults

Cloud Provider Options#Copied!

MilliCache works with managed Redis and Valkey services out of the box. Point MC_STORAGE_HOST at the endpoint your provider gives you; most managed services require TLS (use the tls:// prefix) and password authentication.

Provider Service
AWS ElastiCache (Redis OSS / Valkey)
Google Cloud Memorystore
Azure Azure Cache for Redis
DigitalOcean Managed Caching (Valkey)
Upstash Serverless Redis
Note: Managed services must run in non-cluster mode: a single primary endpoint, optionally with replicas. Cluster mode (sharding across multiple masters) is not supported. If your project requires cluster mode, reach out and tell us about your setup.

Because a managed endpoint is reached over the network rather than localhost, also review the timeout settings if the service runs in a different region than your web servers.

AWS ElastiCache#Copied!

ElastiCache offers both Redis OSS and Valkey engines; both work with MilliCache. Create the cache with cluster mode disabled and connect to the primary endpoint. With in-transit encryption enabled, prefix the host with tls://:

 1define( 'MC_STORAGE_HOST', 'tls://master.example.abc123.euc1.cache.amazonaws.com' );
 2define( 'MC_STORAGE_PORT', 6379 );
 3define( 'MC_STORAGE_PASSWORD', 'your-auth-token' );  // if AUTH is enabled

Google Cloud Memorystore#Copied!

Memorystore instances are reachable over private IP from within the same VPC, so your WordPress servers must run in that network (Compute Engine, GKE, or Cloud Run with a VPC connector):

 1define( 'MC_STORAGE_HOST', '10.0.0.3' );  // instance IP
 2define( 'MC_STORAGE_PORT', 6379 );
 3define( 'MC_STORAGE_PASSWORD', 'your-auth-string' );  // if AUTH is enabled

Azure Cache for Redis#Copied!

Azure exposes caches at *.redis.cache.windows.net with TLS on port 6380. Use an access key as the password:

 1define( 'MC_STORAGE_HOST', 'tls://example.redis.cache.windows.net' );
 2define( 'MC_STORAGE_PORT', 6380 );
 3define( 'MC_STORAGE_PASSWORD', 'your-access-key' );

DigitalOcean Managed Caching#Copied!

DigitalOcean's managed caching service (formerly Managed Redis, now backed by Valkey) requires TLS and provides host, port, username, and password in the control panel's connection details:

 1define( 'MC_STORAGE_HOST', 'tls://db-example-do-user-123456-0.db.ondigitalocean.com' );
 2define( 'MC_STORAGE_PORT', 25061 );
 3define( 'MC_STORAGE_USERNAME', 'default' );
 4define( 'MC_STORAGE_PASSWORD', 'your-password' );

Upstash#Copied!

Upstash offers serverless Redis with per-request pricing. Connections require TLS:

 1define( 'MC_STORAGE_HOST', 'tls://example-12345.upstash.io' );
 2define( 'MC_STORAGE_PORT', 6379 );
 3define( 'MC_STORAGE_PASSWORD', 'your-password' );

Performance Tips#Copied!

  1. Run locally when possible: Same-machine Redis has lowest latency
  2. Use persistent connections: Reduces connection overhead
  3. Enable compression: MC_CACHE_GZIP reduces network transfer
  4. Size memory appropriately: Avoid frequent evictions
  5. Monitor with wp millicache stats: Track cache efficiency

Your storage server can do more than page caching: the Object Cache module in MilliCache Pro ships a persistent object cache drop-in that reuses the same connection, speeding up wp-admin and uncached pages with zero extra setup.

Next Steps#Copied!

Last updated:

Release updates

Get notified when new versions and guides ship. No spam.

By subscribing you agree to our Privacy Policy.­ Double opt-in, no spam, unsubscribe anytime.