Deployment
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.
WP_REDIS_CONFIG
Setting In some scenarios you may wish to set the WP_REDIS_CONFIG
constant programmatically during deployment, you can do so using WP CLI.
#!/usr/bin/env bash
set -e
# Configuration
REDIS_CLIENT="phpredis" # Either `relay` or `phpredis`
REDIS_DATABASE=0 # change for each site (0-15)
OCP_TOKEN="0000000000000000000000000000000"
WP_ROOT="/var/www/example.com/htdocs"
# Download and install plugin
PLUGIN=$(mktemp)
curl -sSL -o $PLUGIN "https://objectcache.pro/plugin/object-cache-pro.zip?token=${OCP_TOKEN}"
unzip $PLUGIN -d "$(wp plugin path --allow-root --path=$WP_ROOT)"
rm $PLUGIN
# Inject `WP_REDIS_CONFIG` config
OCP_CONFIG=$(cat <<EOF
[
'token' => '${OCP_TOKEN}',
'host' => '127.0.0.1',
'port' => 6379,
'database' => $REDIS_DATABASE,
'prefix' => 'db${REDIS_DATABASE}:',
'client' => '${REDIS_CLIENT}',
'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' => false,
'shared' => true,
]
EOF
)
wp config set --raw WP_REDIS_CONFIG "${OCP_CONFIG}"
wp config set --raw WP_REDIS_DISABLED "getenv('WP_REDIS_DISABLED') ?: false"
# Activate plugin
wp plugin activate object-cache-pro
# Hot-swap object cache drop-in and flush
wp redis enable --force
Download URLs
The latest stable version is always available at:
https://objectcache.pro/plugin/object-cache-pro.zip?token=<LICENSE-TOKEN>
To download an older version simply append the version number to the download URL:
https://objectcache.pro/plugin/object-cache-pro-v1.2.3.zip?token=<LICENSE-TOKEN>