Object Cache Pro

Configuration

The configuration of Object Cache Pro is done using the WP_REDIS_CONFIG PHP constant in your wp-config.php file.

Any configuration error will generate an error log entry, and if WP_DEBUG is enabled, additionally throw an exception.

The full list of available configuration options can be found in the options guide.

For most production environments the configuration below is a good starting point:

define('WP_REDIS_CONFIG', [
'token' => '<your-license-token>',
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0, // change for each site
'maxttl' => 3600 * 24 * 7, // 7 days
'timeout' => 1.0,
'read_timeout' => 1.0,
'split_alloptions' => true,
'debug' => false,
]);

define('WP_REDIS_DISABLED', false);

High Performance #

When optimizing high-traffic sites for milliseconds, the configuration below is recommended as well as setting an Eviction Policy.

This configuration requires Redis Server 4.0 (or newer) as well as PhpRedis to be compiled with igbinary and zstd support.

Be sure to read about data encoding to avoid crashing your site when using this configuration.

define('WP_REDIS_CONFIG', [
'token' => '...',
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0, // change for each site
'timeout' => 1.0,
'read_timeout' => 1.0,
'async_flush' => true,
'compression' => 'zstd',
'serializer' => 'igbinary',
'split_alloptions' => true,
'prefetch' => true,
'debug' => false,
'save_commands' => false,
]);

define('WP_REDIS_DISABLED', getenv('WP_REDIS_DISABLED') ?: false);