rhubarbgroup/redis-cache

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

PHP

539

1,393 commits

updated Sep 23, 2026

See the code

README

Redis Object Cache for WordPress

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.

Configuration constantDefaultDescription
WP_REDIS_HOST127.0.0.1The hostname of the Redis server
WP_REDIS_PORT6379The port of the Redis server
WP_REDIS_PATHThe path to the unix socket of the Redis server
WP_REDIS_SCHEMEtcpThe scheme used to connect: tcp or unix
WP_REDIS_DATABASE0The database used by the cache: 0-15
WP_REDIS_PREFIXThe prefix used for all cache keys to avoid data collisions (replaces WP_CACHE_KEY_SALT), should be human readable and not a "salt"
WP_REDIS_PASSWORDThe password of the Redis server, supports Redis ACLs arrays: ['user', 'password']
WP_REDIS_MAXTTL0The maximum time-to-live of cache keys
WP_REDIS_CLIENTThe client used to communicate with Redis (defaults to phpredis when installed, otherwise predis), supports phpredis, predis, relay
WP_REDIS_TIMEOUT1The connection timeout in seconds
WP_REDIS_READ_TIMEOUT1The timeout in seconds when reading/writing
WP_REDIS_IGNORED_GROUPS[]Groups that should not be cached between requests in Redis (read more)
Advanced configuration options
Configuration constantDefaultDescription
WP_CACHE_KEY_SALTDeprecated. Replaced by WP_REDIS_PREFIX
WP_REDIS_SSL_CONTEXT[]TLS connection options for tls or rediss scheme
WP_REDIS_FLUSH_TIMEOUT5Experimental. The timeout in seconds when flushing
WP_REDIS_RETRY_INTERVALThe number of milliseconds between retries (PhpRedis only)
WP_REDIS_PERSISTENTfalseWhether to persistent connections. Optionally, accepts non-empty connection identifier string.
WP_REDIS_GLOBAL_GROUPS[]Additional groups that are considered global on multisite networks
WP_REDIS_CHART_COLOROverride admin metrics chart color using a hex value (#RGB or #RRGGBB)
WP_REDIS_METRICS_MAX_TIME3600The maximum number of seconds metrics should be stored
WP_REDIS_IGBINARYfalseWhether to use the igbinary PHP extension for serialization
WP_REDIS_DISABLEDfalseEmergency switch to bypass the object cache without deleting the drop-in
WP_REDIS_DISABLE_ADMINBARfalseDisables admin bar display
WP_REDIS_DISABLE_METRICSfalseDisables metrics collection and display
WP_REDIS_DISABLE_DROPIN_CHECKfalseDisables the extended drop-in write test
WP_REDIS_DISABLE_DROPIN_AUTOUPDATEfalseDisables the drop-in auto-update
WP_REDIS_DISABLE_GROUP_FLUSHfalseDisables group flushing with Lua script and uses flushdb call instead
WP_REDIS_DISABLE_BANNERSfalseDisables promotional banners and notices
WP_REDIS_DISABLE_COMMENTfalseDisables HTML source comment
WP_REDIS_LOAD_APEXCHARTStrueWhether to load the ApexCharts script
WP_REDIS_MANAGER_CAPABILITYThe capability a user must have to manage the plugin
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:

Configuration constantDefaultDescription
WP_REDIS_GRACEFULfalsePrevents exceptions from being thrown, but will cause data corruption
WP_REDIS_SELECTIVE_FLUSHfalseUses terribly slow Lua script for flushing
WP_REDIS_UNFLUSHABLE_GROUPS[]Uses terribly slow Lua script to prevent groups from being flushed

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.

CommandDescription
wp redis statusShows the object cache status and diagnostics
wp redis enableEnables the object cache
wp redis disableDisables the object cache
wp redis update-dropinUpdates the object cache drop-in

Actions & Filters

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

Filter / ActionDescription
redis_cache_expirationFilters the cache expiration for individual keys
redis_cache_validate_dropinFilters whether the drop-in is valid
redis_cache_add_non_persistent_groupsFilters the groups to be marked as non persistent
redis_cache_manager_capabilityFilters the capability a user needs to manage the plugin

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.

cache
php
phpredis
predis
redis
relay
wordpress
wordpress-plugin

Significant stargazers

Michael Grunder

191 followers · starred Nov 2019

Roman Gershman

1,047 followers · starred Jun 2023

Zack Corr

57 followers · starred Nov 2019

CodeShakingSheep

4 followers · starred Jan 2026

rhubarbgroup/redis-cache

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

PHP

539

1,393 commits

updated Sep 23, 2026

See the code

README

Redis Object Cache for WordPress

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.

Configuration constantDefaultDescription
WP_REDIS_HOST127.0.0.1The hostname of the Redis server
WP_REDIS_PORT6379The port of the Redis server
WP_REDIS_PATHThe path to the unix socket of the Redis server
WP_REDIS_SCHEMEtcpThe scheme used to connect: tcp or unix
WP_REDIS_DATABASE0The database used by the cache: 0-15
WP_REDIS_PREFIXThe prefix used for all cache keys to avoid data collisions (replaces WP_CACHE_KEY_SALT), should be human readable and not a "salt"
WP_REDIS_PASSWORDThe password of the Redis server, supports Redis ACLs arrays: ['user', 'password']
WP_REDIS_MAXTTL0The maximum time-to-live of cache keys
WP_REDIS_CLIENTThe client used to communicate with Redis (defaults to phpredis when installed, otherwise predis), supports phpredis, predis, relay
WP_REDIS_TIMEOUT1The connection timeout in seconds
WP_REDIS_READ_TIMEOUT1The timeout in seconds when reading/writing
WP_REDIS_IGNORED_GROUPS[]Groups that should not be cached between requests in Redis (read more)
Advanced configuration options
Configuration constantDefaultDescription
WP_CACHE_KEY_SALTDeprecated. Replaced by WP_REDIS_PREFIX
WP_REDIS_SSL_CONTEXT[]TLS connection options for tls or rediss scheme
WP_REDIS_FLUSH_TIMEOUT5Experimental. The timeout in seconds when flushing
WP_REDIS_RETRY_INTERVALThe number of milliseconds between retries (PhpRedis only)
WP_REDIS_PERSISTENTfalseWhether to persistent connections. Optionally, accepts non-empty connection identifier string.
WP_REDIS_GLOBAL_GROUPS[]Additional groups that are considered global on multisite networks
WP_REDIS_CHART_COLOROverride admin metrics chart color using a hex value (#RGB or #RRGGBB)
WP_REDIS_METRICS_MAX_TIME3600The maximum number of seconds metrics should be stored
WP_REDIS_IGBINARYfalseWhether to use the igbinary PHP extension for serialization
WP_REDIS_DISABLEDfalseEmergency switch to bypass the object cache without deleting the drop-in
WP_REDIS_DISABLE_ADMINBARfalseDisables admin bar display
WP_REDIS_DISABLE_METRICSfalseDisables metrics collection and display
WP_REDIS_DISABLE_DROPIN_CHECKfalseDisables the extended drop-in write test
WP_REDIS_DISABLE_DROPIN_AUTOUPDATEfalseDisables the drop-in auto-update
WP_REDIS_DISABLE_GROUP_FLUSHfalseDisables group flushing with Lua script and uses flushdb call instead
WP_REDIS_DISABLE_BANNERSfalseDisables promotional banners and notices
WP_REDIS_DISABLE_COMMENTfalseDisables HTML source comment
WP_REDIS_LOAD_APEXCHARTStrueWhether to load the ApexCharts script
WP_REDIS_MANAGER_CAPABILITYThe capability a user must have to manage the plugin
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:

Configuration constantDefaultDescription
WP_REDIS_GRACEFULfalsePrevents exceptions from being thrown, but will cause data corruption
WP_REDIS_SELECTIVE_FLUSHfalseUses terribly slow Lua script for flushing
WP_REDIS_UNFLUSHABLE_GROUPS[]Uses terribly slow Lua script to prevent groups from being flushed

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.

CommandDescription
wp redis statusShows the object cache status and diagnostics
wp redis enableEnables the object cache
wp redis disableDisables the object cache
wp redis update-dropinUpdates the object cache drop-in

Actions & Filters

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

Filter / ActionDescription
redis_cache_expirationFilters the cache expiration for individual keys
redis_cache_validate_dropinFilters whether the drop-in is valid
redis_cache_add_non_persistent_groupsFilters the groups to be marked as non persistent
redis_cache_manager_capabilityFilters the capability a user needs to manage the plugin

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.

cache
php
phpredis
predis
redis
relay
wordpress
wordpress-plugin

Significant stargazers

Michael Grunder

191 followers · starred Nov 2019

Roman Gershman

1,047 followers · starred Jun 2023

Zack Corr

57 followers · starred Nov 2019

CodeShakingSheep

4 followers · starred Jan 2026

Languages

PHP

86.8%

HTML

5.9%

JavaScript

5.7%

CSS

1.2%