rhubarbgroup/redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.

Fund package maintenance!
tillkruss
www.paypal.me/tillkruss

Installs: 75 146

Dependents: 1

Suggesters: 0

Security: 0

Stars: 447

Watchers: 24

Forks: 151

Open Issues: 7

Type:wordpress-plugin


README

A persistent object cache backend powered by Redis®¹. Supports Predis, PhpRedis (PECL), Relay, replication, sentinels, clustering and WP-CLI.

Redis Object Cache screenshots

Object Cache Pro

A business class Redis®¹ object cache backend. Truly reliable, highly optimized, fully customizable and with a dedicated engineer when you most need it.

  • Rewritten for raw performance
  • 100% WordPress API compliant
  • Faster serialization and compression
  • Easy debugging & logging
  • Cache prefetching and advanced analytics
  • Fully unit tested (100% code coverage)
  • Optimized for WooCommerce, Jetpack & Yoast SEO
  • And much more...

Installation

To get started, please see the installation instructions.

FAQ & Troubleshooting

Answers to common questions and troubleshooting of common errors can be found in the FAQ.

Configuration

The Redis Object Cache plugin comes with vast set of configuration options. If you're unsure how to use them read the installation instructions.

Advanced configuration options
Unsupported configuration options

Options that exist, but should not, may break without notice in future releases and won't receive any support whatsoever from our team:

Connections

Connecting over Unix socket
define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/var/run/redis.sock' );
Connecting over TCP+TLS
define( 'WP_REDIS_SCHEME', 'tls' );
define( 'WP_REDIS_HOST', 'master.ncit.ameaqx.use1.cache.amazonaws.com' );
define( 'WP_REDIS_PORT', 6379 );

Additional TLS/SSL stream connection options for connections can be defined using WP_REDIS_SSL_CONTEXT:

define( 'WP_REDIS_SSL_CONTEXT', [
    'verify_peer' => false,
    'verify_peer_name' => false,
]);
Connecting using ACL authentication
define( 'WP_REDIS_PASSWORD', [ 'username', 'password' ] );

Scaling

Redis Object Cache offers various replication, sharding, cluster and sentinel setups to users with advanced technical knowledge of Redis and PHP, that have consulted the Predis, PhpRedis or Relay documentation.

Relay

Relay is a next-generation cache that keeps a partial replica of Redis' dataset in PHP's memory for ridiculously fast lookups, especially when Redis Server is not on the same machine as WordPress.

define( 'WP_REDIS_CLIENT', 'relay' );

define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );

// when using Relay, each WordPress installation
// MUST a dedicated Redis database and unique prefix
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_PREFIX', 'db3:' );

// consume less memory
define( 'WP_REDIS_IGBINARY', true );
Replication

https://redis.io/docs/management/replication/

define( 'WP_REDIS_CLIENT', 'predis' );

define( 'WP_REDIS_SERVERS', [
    'tcp://127.0.0.1:6379?database=5&role=master',
    'tcp://127.0.0.2:6379?database=5&alias=replica-01',
] );
Sharding

This is a PhpRedis specific feature using RedisArray.

define( 'WP_REDIS_CLIENT', 'phpredis' );

define( 'WP_REDIS_SHARDS', [
    'tcp://127.0.0.1:6379?database=10&alias=shard-01',
    'tcp://127.0.0.2:6379?database=10&alias=shard-02',
    'tcp://127.0.0.3:6379?database=10&alias=shard-03',
] );
Redis Sentinel

https://redis.io/docs/management/sentinel/

define( 'WP_REDIS_CLIENT', 'predis' );

define( 'WP_REDIS_SENTINEL', 'my-sentinel' );
define( 'WP_REDIS_SERVERS', [
    'tcp://127.0.0.1:5380',
    'tcp://127.0.0.2:5381',
    'tcp://127.0.0.3:5382',
] );
Redis Cluster

https://redis.io/docs/management/scaling/

define( 'WP_REDIS_CLIENT', 'phpredis' );

define( 'WP_REDIS_CLUSTER', [
    'tcp://127.0.0.1:6379?alias=node-01',
    'tcp://127.0.0.2:6379?alias=node-02',
    'tcp://127.0.0.3:6379?alias=node-03',
] );

WP CLI commands

Redis Object Cache has various WP CLI commands, for more information run wp help redis.

Actions & Filters

Redis Object Cache has various hooks and the commonly used ones are listed below.

Footnotes

¹ Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by Redis Object Cache is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and Redis Object Cache.