Relay
If the Relay PHP extension is installed on your system, using it with Object Cache Pro is as easy as setting the client
configuration option.
There are however a few important things to know:
- Disable prefetching, it will slow down Relay
- Turn on
alloptions
splitting - Use compression and igbinary to reduce Relay memory usage
- Understand multitenancy limitations
Multitenancy limitations
With Relay enabled, running multiple WordPress sites on a single Redis instance has some limitations, which will cause unnecessary flushing of Relay’s memory.
To bypass most of them, it is vital to:
- Use a dedicated
database
for each WordPress site - As well as, a unique
prefix
for each WordPress site
Unfortunately, due to Redis’ design, Relay isn’t aware of the database index
when FLUSHDB
is called and thus will flush it’s entire memory.
If you’re curious, read the technical details.
Relay configuration
define('WP_REDIS_CONFIG', [
'token' => '...',
'host' => '127.0.0.1',
'port' => 6379,
// use `relay` extension
'client' => 'relay',
// avoid unnecessary flushing
'database' => 3,
'prefix' => 'db3:',
// whether the Redis instance is shared
'shared' => true,
// reduce memory usage
'compression' => 'zstd',
'serializer' => 'igbinary',
// optimize for Relay
'prefetch' => false,
'split_alloptions' => true,
]);