Must Use Setup

Object Cache Pro can run as a Must-Use Plugin and can even be located outside the mu-plugins directory, when the WP_REDIS_DIR constant is used.

Using Composer

If the plugin is installed using Composer, a post-update-cmd script can that automatically configure the setup for you.

The script below will copy the stub as well as the plugin directory to the mu-plugins directory after each Composer update.

{
  "scripts": {
    "post-update-cmd": [
      "cp wp-content/plugins/object-cache-pro/stubs/mu-plugin.php wp-content/mu-plugins/object-cache-pro.php",
      "cp -r wp-content/plugins/object-cache-pro wp-content/mu-plugins/"
    ]
  },
}

Plugin Directory

In some cases, like shared environments or managed hosting, Object Cache Pro might needs to be located outside your web root directory. This can easily be accomplished the WP_REDIS_DIR constant and the must-use stub.

First, define the constant near your WP_REDIS_CONFIG.

define('WP_REDIS_DIR', '/path/to/object-cache-pro');

define('WP_REDIS_CONFIG', [
    // ...
]);

Next, set up a Composer post-update-cmd script in your composer.json to install the plugin and copy the must-use stub:

{
  "scripts": {
    "post-update-cmd": [
      "cd /path/to/ && composer update",
      "cp /path/to/object-cache-pro/stubs/mu-plugin.php wp-content/mu-plugins/object-cache-pro.php"
    ]
  }
}

That’s it.