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.
Recommended Configuration #
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 for milliseconds, the configuration below is recommended as well as setting an Eviction Policy.
This configuration requires:
- Redis 4.0+
- PhpRedis 5.1+ compiled with
igbinary
andzstd
support
define('WP_REDIS_CONFIG', [
'token' => '...',
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0, // change for each site
'timeout' => 0.5,
'read_timeout' => 0.5,
'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);
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.