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' => '...',
// 'host' => '127.0.0.1',
// 'port' => 6379,
// 'password' => 'secret',
// 'database' => 0,
'maxttl' => 3600 * 24 * 7, // 7 days
'timeout' => 1.0,
'read_timeout' => 1.0,
'debug' => false,
]);

High Performance #

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

This configuration requires:

  • Redis 4.0.0 or newer
  • PhpRedis 5.1.0 or newer compiled with igbinary and zstd support
define('WP_REDIS_CONFIG', [
'token' => '...',
// 'host' => '127.0.0.1',
// 'port' => 6379,
// 'password' => 'secret',
// 'database' => 0,
'timeout' => 0.5,
'read_timeout' => 0.5,
'async_flush' => true,
'compression' => 'zstd',
'serializer' => 'igbinary',
'split_alloptions' => true,
'debug' => false,
'save_commands' => false,
]);

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

It might also be necessary to have access to redis-cli to flush the cache after deploying this configuration, in case of compression/serialization conflicts.