v2.1.4

Apex Cache Pro Documentation

Redis object caching built for serious WordPress. — Complete reference including installation, configuration, CLI commands, hooks, and troubleshooting.

🚀

Getting Started

1Overview

Apex Cache Pro replaces the default WordPress object cache with a hardened, Redis-backed persistent cache engine. It dramatically reduces database load by storing computed results in Redis — an in-memory data store that responds in sub-millisecond time.

Unlike the built-in WordPress transient and object cache (which is non-persistent by default), Apex Cache Pro persists cached objects across requests, meaning the database is only hit when the cache is cold or explicitly invalidated.

The plugin supports single Redis instances, Redis Cluster, and Redis Sentinel topologies. It works with phpredis, Predis, and Relay clients, and includes full multisite support with per-site cache isolation.

2System Requirements

ComponentMinimumRecommended
WordPress5.6+6.4+
PHP7.4+8.2+
Redis Server6.0+7.2+
PHP Extensionphpredis 5.0+ or Predis 2.0+phpredis 6.0+ or Relay

Note: Relay is a next-generation Redis client for PHP that provides a shared in-memory cache. It offers the best performance but requires a separate license.

3Installation

Via WordPress Admin

  1. Purchase a license at apexstack.cloud/pricing
  2. Download the plugin ZIP from your account dashboard
  3. In WordPress, go to Plugins → Add New → Upload Plugin
  4. Upload the ZIP file and click Install Now
  5. Click Activate Plugin

Via WP-CLI

# Upload and activate
wp plugin install /path/to/apex-cache-pro.zip --activate

# Verify installation
wp plugin list --name=apex-cache-pro --format=table

Apex Cache Pro installs an object cache drop-in at wp-content/object-cache.php. If another caching plugin already has a drop-in file, you will need to remove it first.

4License Activation

Via Dashboard

Navigate to Settings → Apex Cache Pro → License and enter your license key. Click Activate. The plugin will verify your key against the Apex Stack license server and enable all features.

Via WP-CLI

# Activate license
wp apex-cache license activate YOUR-LICENSE-KEY

# Check license status
wp apex-cache license status

# Deactivate (e.g., before migrating to a new server)
wp apex-cache license deactivate

Each license key is tied to a site URL. If you migrate your site to a new domain, deactivate the license on the old domain first, then re-activate on the new one.

⚙️

Configuration

1Redis Connection

Configure the Redis connection by adding constants to your wp-config.php file, before the line that says /* That's all, stop editing! */.

/* Redis connection */
define('APEX_REDIS_HOST', '127.0.0.1');
define('APEX_REDIS_PORT', 6379);
define('APEX_REDIS_PASSWORD', 'your-redis-password');
define('APEX_REDIS_DATABASE', 0);
define('APEX_REDIS_PREFIX', 'wp_');
ConstantDefaultDescription
APEX_REDIS_HOST127.0.0.1Redis server hostname or IP address
APEX_REDIS_PORT6379Redis server port
APEX_REDIS_PASSWORDnullRedis AUTH password (or ACL user:pass)
APEX_REDIS_DATABASE0Redis database index (0-15)
APEX_REDIS_PREFIXwp_Key prefix to namespace this site's cache

TLS / SSL Connections

For encrypted connections (e.g., AWS ElastiCache with in-transit encryption):

define('APEX_REDIS_SCHEME', 'tls');
define('APEX_REDIS_SSL_VERIFY', true);    // Verify server certificate
define('APEX_REDIS_SSL_CA', '/path/to/ca.pem'); // Optional CA bundle

2Client Selection

Apex Cache Pro supports three Redis client libraries. Set the client in wp-config.php:

define('APEX_REDIS_CLIENT', 'phpredis'); // 'phpredis', 'predis', or 'relay'
ClientTypePerformanceRequirements
phpredisC extensionFastpecl install redis
PredisPHP libraryGoodBundled with plugin
RelayC extension + shared memoryFastestSeparate license

Recommendation: Use phpredis for most installations. It's the most widely supported and offers excellent performance. Use Relay for high-traffic sites where shared in-memory caching provides additional benefits.

3Cluster & Sentinel

Redis Cluster

For Redis Cluster deployments, define an array of cluster nodes:

define('APEX_REDIS_CLUSTER', [
    'tcp://redis-node-1:6379',
    'tcp://redis-node-2:6379',
    'tcp://redis-node-3:6379',
]);

// Optional: cluster-specific settings
define('APEX_REDIS_CLUSTER_FAILOVER', 'error'); // 'none', 'error', 'distribute'

Redis Sentinel

For Redis Sentinel (high-availability) deployments:

define('APEX_REDIS_SENTINELS', [
    'tcp://sentinel-1:26379',
    'tcp://sentinel-2:26379',
    'tcp://sentinel-3:26379',
]);
define('APEX_REDIS_SENTINEL_SERVICE', 'mymaster');

When using Cluster or Sentinel, do not set APEX_REDIS_HOST / APEX_REDIS_PORT. The cluster/sentinel configuration takes precedence.

4Multisite Configuration

Apex Cache Pro fully supports WordPress Multisite. By default, each sub-site gets its own cache prefix based on the blog ID.

// Share cache across all sites (use with caution)
define('APEX_REDIS_MULTISITE_GLOBAL', true);

// Control network-wide flush behavior
define('APEX_REDIS_MULTISITE_FLUSH', 'site'); // 'site' or 'network'
ConstantDefaultDescription
APEX_REDIS_MULTISITE_GLOBALfalseIf true, all sites share the same cache namespace
APEX_REDIS_MULTISITE_FLUSHsiteWhether flushing affects just the current site or the entire network

5Advanced Options

// Maximum TTL for cached objects (seconds, 0 = no limit)
define('APEX_REDIS_MAXTTL', 0);

// Connection timeout (seconds)
define('APEX_REDIS_TIMEOUT', 1);

// Read timeout (seconds)
define('APEX_REDIS_READ_TIMEOUT', 1);

// Retry interval on connection failure (milliseconds)
define('APEX_REDIS_RETRY_INTERVAL', 100);

// Cache groups that should NOT be persisted in Redis
define('APEX_REDIS_IGNORED_GROUPS', [
    'counts', 'plugins', 'themes',
]);

// Cache groups that should NOT be flushed
define('APEX_REDIS_UNFLUSHABLE_GROUPS', [
    'user_meta', 'userslugs',
]);

The APEX_REDIS_IGNORED_GROUPS constant is useful for cache groups that change frequently and don't benefit from persistence. The default WordPress counts group is a common candidate.

💻

WP-CLI Commands

1Command Overview

Apex Cache Pro provides a full set of WP-CLI commands under the wp apex-cache namespace.

CommandDescription
wp apex-cache statusDisplay cache connection status and statistics
wp apex-cache enableInstall the object cache drop-in
wp apex-cache disableRemove the object cache drop-in
wp apex-cache flushFlush the entire object cache
wp apex-cache diagnosticsRun connection and performance diagnostics
wp apex-cache licenseManage license activation

2Full Reference

wp apex-cache status

Displays current cache connection info, hit/miss ratio, memory usage, and key count.

$ wp apex-cache status

+-----------------+---------------------+
| Property        | Value               |
+-----------------+---------------------+
| Status          | Connected           |
| Client          | phpredis 6.0.2      |
| Host            | 127.0.0.1:6379      |
| Database        | 0                   |
| Key Prefix      | wp_                 |
| Keys            | 4,281               |
| Memory Used     | 12.4 MB             |
| Hit Ratio       | 94.7%               |
| Uptime          | 14d 6h 32m          |
+-----------------+---------------------+

wp apex-cache flush

Flush the cache. Optionally flush a specific cache group.

# Flush everything
wp apex-cache flush

# Flush a specific group
wp apex-cache flush --group=transients

# Flush on a specific multisite blog
wp apex-cache flush --url=sub.example.com

wp apex-cache diagnostics

Runs a comprehensive diagnostic check on the Redis connection, extension compatibility, and drop-in integrity.

$ wp apex-cache diagnostics

Running diagnostics...
 ✓ Redis connection: OK (0.4ms latency)
 ✓ PHP extension: phpredis 6.0.2
 ✓ Redis version: 7.2.3
 ✓ Drop-in file: intact (checksum match)
 ✓ Memory: 12.4 MB / 256 MB (4.8%)
 ✓ Eviction policy: allkeys-lru
 ✓ Persistence: RDB enabled
 
All 7 checks passed.
🪝

Hooks & Filters

1Action Hooks

HookFired WhenParameters
apex_cache_connectedRedis connection established$client
apex_cache_flushedEntire cache flushed
apex_cache_flush_groupA specific group is flushed$group
apex_cache_errorA Redis error occurs$exception

Example: Purge CDN after cache flush

add_action('apex_cache_flushed', function () {
    // Trigger CDN purge after WordPress cache is cleared
    wp_remote_post('https://api.cdn.example.com/purge', [
        'headers' => ['Authorization' => 'Bearer ' . CDN_API_KEY],
    ]);
});

2Filter Hooks

FilterDescriptionParameters
apex_cache_keyModify cache keys before storage$key, $group
apex_cache_ttlOverride TTL for specific groups$ttl, $group
apex_cache_ignored_groupsModify the list of ignored groups$groups
apex_cache_should_cacheConditionally skip caching$should, $key, $group
apex_cache_connection_paramsModify Redis connection parameters$params

Example: Custom TTL per group

add_filter('apex_cache_ttl', function ($ttl, $group) {
    // Short TTL for transients, longer for options
    if ($group === 'transients') return 300;   // 5 minutes
    if ($group === 'options')    return 3600;  // 1 hour
    return $ttl;
}, 10, 2);

Example: Skip caching for specific keys

add_filter('apex_cache_should_cache', function ($should, $key, $group) {
    // Don't cache WooCommerce session data in Redis
    if ($group === 'wc_session_id') return false;
    return $should;
}, 10, 3);
🔧

Troubleshooting

1Common Issues

IssueCauseSolution
Connection refusedRedis not running or wrong host/portVerify Redis is running: redis-cli ping
Authentication failedWrong password or ACL misconfigurationCheck APEX_REDIS_PASSWORD matches Redis requirepass
Timeout errorsNetwork latency or Redis overloadedIncrease APEX_REDIS_TIMEOUT, check Redis slow log
Drop-in conflictAnother plugin's object-cache.php existsRemove the other plugin's drop-in, then run wp apex-cache enable
Serialization errorsObjects with closures or resourcesAdd the problematic group to APEX_REDIS_IGNORED_GROUPS

2Debug Logging

Enable verbose logging to diagnose connection or performance issues:

define('APEX_REDIS_DEBUG', true);
define('APEX_REDIS_DEBUG_LOG', '/tmp/apex-cache-debug.log');

Warning: Debug logging generates a large amount of output and will impact performance. Only enable it temporarily during troubleshooting, and never in production under normal operation.

Log entries include timestamps, operation type, key, group, result (hit/miss), and latency in microseconds.

3Performance Tuning

Redis Server Configuration

For optimal performance with WordPress object caching, we recommend these Redis settings:

# /etc/redis/redis.conf
maxmemory 256mb
maxmemory-policy allkeys-lru
save ""
appendonly no
  • maxmemory-policy allkeys-lru — Evict least-recently-used keys when memory is full
  • Disable persistence — Object cache data is ephemeral; persistence adds unnecessary I/O
  • Set appropriate maxmemory — 256 MB handles most sites; increase for large multisite installs

WordPress Configuration

// Set a reasonable max TTL to prevent stale data
define('APEX_REDIS_MAXTTL', 86400); // 24 hours

// Ignore groups that don't benefit from caching
define('APEX_REDIS_IGNORED_GROUPS', [
    'counts', 'plugins', 'themes',
]);

5 categories · 16 sections · Apex Cache Pro v2.1.4