Its not recommended to commit the object-cache.php drop-in to your version control by adding it to your .gitignore file.

If you do commit it, its recommended to use a Composer script to keep it up-to-date automatically. This ensure the drop-in stays up-to-date.

  "scripts": {
    "post-update-cmd": [
      "wp redis enable --force"

If WP CLI is not available, you can also automatically update the drop-in after each composer update as shown below.

  "scripts": {
    "post-update-cmd": [
      "@php -r \"copy('wp-content/plugins/object-cache-pro/stubs/object-cache.php', 'wp-content/object-cache.php');\""

You might need to adjust the paths above. To test the script run:

composer run post-update-cmd

You may of course use our own deployment script instead of using Composer scripts.


In some scenarios you may wish to set the WP_REDIS_CONFIG constant programmatically during deployment, you can do so using WP CLI.

set -e

read -r -d '' WP_REDIS_CONFIG <<- EOM
    'token' => getenv('OBJECTCACHEPRO_TOKEN'),
    'url' => getenv('REDIS_URL'),
    'timeout' => 0.5,
    'read_timeout' => 0.5,
    'retry_interval' => 10,
    'retries' => 3,
    'backoff' => 'smart',
    'compression' => 'zstd',
    'serializer' => 'igbinary',
    'async_flush' => true,
    'split_alloptions' => true,
    'prefetch' => true,
    'debug' => false,

wp config set --raw WP_REDIS_CONFIG "${WP_REDIS_CONFIG}"
wp config set --raw WP_REDIS_DISABLED "getenv('WP_REDIS_DISABLED') ?: false"