Redis Object Cache


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

To adjust the connection parameters, prefix cache keys or configure replication/clustering, please see Other Notes.

Forked from Eric Mann’s and Erick Hitter’s Redis Object Cache.

Redis 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
  • WordPress object cache API compliant
  • Easy debugging & logging
  • Cache analytics and preloading
  • Fully unit tested (100% code coverage)
  • Secure connections with TLS
  • Health checks via WordPress, WP CLI & Debug Bar
  • Optimized for WooCommerce, Jetpack & Yoast SEO

Learn more about Redis Cache Pro.

Connection Parameters

By default the object cache drop-in will connect to Redis over TCP at and select database 0.

To adjust the connection parameters, define any of the following constants in your wp-config.php file.

  • WP_REDIS_CLIENT (default: not set)

    Specifies the client used to communicate with Redis. Supports hhvm, pecl and predis.

  • WP_REDIS_SCHEME (default: tcp)

    Specifies the protocol used to communicate with an instance of Redis. Internally the client uses the connection class associated to the specified connection scheme. Supports tcp (TCP/IP), unix (UNIX domain sockets), tls (transport layer security) or http (HTTP protocol through Webdis).

  • WP_REDIS_HOST (default:

    IP or hostname of the target server. This is ignored when connecting to Redis using UNIX domain sockets.

  • WP_REDIS_PORT (default: 6379)

    TCP/IP port of the target server. This is ignored when connecting to Redis using UNIX domain sockets.

  • WP_REDIS_PATH (default: not set)

    Path of the UNIX domain socket file used when connecting to Redis using UNIX domain sockets.

  • WP_REDIS_DATABASE (default: 0)

    Accepts a numeric value that is used to automatically select a logical database with the SELECT command.

  • WP_REDIS_PASSWORD (default: not set)

    Accepts a value used to authenticate with a Redis server protected by password with the AUTH command.

  • WP_REDIS_TIMEOUT (default: 5)

    Amount of time in seconds (fractions of a second allowed) to attempt initial connection to Redis server before failing.

  • WP_REDIS_READ_TIMEOUT (default: 5)

    Amount of time in seconds (fractions of a second allowed) to attempt a read from the Redis server before failing.

  • WP_REDIS_RETRY_INTERVAL (default: not set)

    Amount of time in milliseconds to retry a failed connection attempt.

    Configuration Options

    To adjust the configuration, define any of the following constants in your wp-config.php file.

  • WP_CACHE_KEY_SALT (default: not set)

    Set the prefix for all cache keys. Useful in setups where multiple installs share a common wp-config.php or $table_prefix to guarantee uniqueness of cache keys.

  • WP_REDIS_SELECTIVE_FLUSH (default: not set)

    If set to true, flushing the cache will only delete keys that are prefixed with WP_CACHE_KEY_SALT (instead of emptying the entire Redis database). The selective flush is an atomic O(n) operation.

  • WP_REDIS_MAXTTL (default: not set)

    Set maximum time-to-live (in seconds) for cache keys with an expiration time of 0.

  • WP_REDIS_GLOBAL_GROUPS (default: ['blog-details', 'blog-id-cache', 'blog-lookup', 'global-posts', 'networks', 'rss', 'sites', 'site-details', 'site-lookup', 'site-options', 'site-transient', 'users', 'useremail', 'userlogins', 'usermeta', 'user_meta', 'userslugs'])

    Set the list of network-wide cache groups that should not be prefixed with the blog-id (Multisite only).

  • WP_REDIS_IGNORED_GROUPS (default: ['counts', 'plugins'])

    Set the cache groups that should not be cached in Redis.

  • WP_REDIS_UNFLUSHABLE_GROUPS (default: not set)

    Set groups not being flushed during a selective cache flush.

  • WP_REDIS_DISABLED (default: not set)

    Set to true to disable the object cache at runtime.

  • WP_REDIS_GRACEFUL (default: not set)

    Set to false to disable graceful failures and throw exceptions.

  • WP_REDIS_SERIALIZER (default: not set)

    Use PhpRedis’ built-in serializers. Supported values are Redis::SERIALIZER_PHP and Redis::SERIALIZER_IGBINARY.

  • WP_REDIS_IGBINARY (default: not set)

    Set to true to enable the igbinary serializer. Ignored when WP_REDIS_SERIALIZER is set.

  • WP_REDIS_DISABLE_BANNERS (default: not set)

    Set to true to disable promotions for Redis Cache Pro.

  • WP_REDIS_DISABLE_COMMENT (default: not set)

    Set to true to disable the HTML footer comment and it’s optional debugging information when WP_DEBUG is enabled.

    Replication & Clustering

    To use Replication, Sharding or Clustering, make sure your server is running PHP7 or higher (HHVM is not supported) and you consulted the Predis or PhpRedis documentation.

For replication use the WP_REDIS_SERVERS constant, for sharding the WP_REDIS_SHARDS constant and for clustering the WP_REDIS_CLUSTER constant.

For authentication use the WP_REDIS_PASSWORD constant.

Replication (Master-Slave):

define( 'WP_REDIS_SERVERS', [
] );

Replication (Redis Sentinel):

define( 'WP_REDIS_CLIENT', 'predis' );
define( 'WP_REDIS_SENTINEL', 'mymaster' );
define( 'WP_REDIS_SERVERS', [
] );


define( 'WP_REDIS_SHARDS', [
] );

Clustering (Redis 3.0+):

define( 'WP_REDIS_CLUSTER', [
] );<h3>WP-CLI Commands</h3>

To use the WP-CLI commands, make sure the plugin is activated:

wp plugin activate redis-cache

The following commands are supported:

  • wp redis status

    Show the Redis object cache status and (when possible) client.

  • wp redis enable

    Enables the Redis object cache. Default behavior is to create the object cache drop-in, unless an unknown object cache drop-in is present.

  • wp redis disable

    Disables the Redis object cache. Default behavior is to delete the object cache drop-in, unless an unknown object cache drop-in is present.

  • wp redis update-dropin

    Updates the Redis object cache drop-in. Default behavior is to overwrite any existing object cache drop-in.


  • Plugin settings, connected to a single Redis server.

  • Plugin settings, not connected to a Redis cluster.


For detailed installation instructions, please read the standard installation procedure for WordPress plugins.

  1. Make sure Redis is installed and running.
  2. Install and activate plugin.
  3. Enable the object cache under Settings -> Redis, or in Multisite setups under Network Admin -> Settings -> Redis.
  4. If necessary, adjust connection parameters.

If your server doesn’t support the WordPress Filesystem API, you have to manually copy the object-cache.php file from the /plugins/redis-cache/includes/ directory to the /wp-content/ directory.


5 de junio de 2020
Yes, it's no accident if this is THE WordPress plugin when doing object caching. However, one thing that may fly under the radar is Till's absolute dedication to support his product. I had a truly arcane issue and he was willing to go the extra mile to diagnose it. I can't stress how rare this is and how this makes the Redis Object Cache such a valuable tool in one's arsenal. A simple "5 stars" rating doesn't do it justice.
2 de junio de 2020
Redis is the best platform to offer cache on your site. This plugin is hands down the absolute best option. Developer is very helpful, we have ran on our production Woocommerce site for several years with no major issues. Highly recommend.
31 de mayo de 2020
Have my site hosted with Cloudways, and this plugin works great, connecting to the redis server - installed on the webserver. Regular updates, and fast support.
31 de mayo de 2020
Using this plugin as part of our standard WordPress configuration for my customers in about 60 separate instances improving their WordPress backend performance considerably. Most users will install the plugin and, given that you are using the default Redis configuration, no further setup will be required. For any other Redis configuration there are configuration constants that can be set (particularly nice for small scale hosters). Backwards-compatibility is outstanding as even multiple year old Redis and phpredis versions are still supported by the plugin. Even if you don't have the option to install or activate the php redis module the plugin will still function as it bundles a pure php implementation to talk to the Redis instance.
30 de mayo de 2020
I've never used Redis before, but I moved to CloudWays hosting and their virtual servers fully support it. There's some good KB's on their site on how to set it up and how to use this very plugin. Recently there was an update issue and the plugin developer resolved it VERY quickly, which speaks volumes to why I give this a 5-star.
Leer todas las 76 reseñas

Colaboradores y desarrolladores

«Redis Object Cache» es un software de código abierto. Las siguientes personas han colaborado con este plugin.


«Redis Object Cache» ha sido traducido a 6 idiomas locales. Gracias a los traductores por sus contribuciones.

Traduce «Redis Object Cache» a tu idioma.

¿Interesado en el desarrollo?

Revisa el código , echa un vistazo al repositorio SVN o suscríbete al registro de desarrollo por RSS.

Registro de cambios


  • Fixed issue with footer comment showing during AJAX requests


  • Improved group name sanitization (thanks @naxvog)
  • Prevent fatal error when replacing foreign dropin
  • Added HTML footer comment with optional debug information
  • Removed prefix suggestions

The HTML footer comment only prints debug information when WP_DEBUG is enabled. To disable the comment entirely, set the WP_REDIS_DISABLE_COMMENT constant to true.


  • Fixed missing $info variable assignment in constructor
  • Fixed MaxTTL warning condition
  • Switched to using default button styles


  • Added warning message about invalid MaxTTL
  • Added warning about unmaintained Predis library
  • Added suggestion about shorter, human-readable prefixes
  • Added Redis Cache Pro compatibility to settings
  • Fixed flushing the cache when the prefix contains special characters
  • Fixed calling Redis INFO when using clusters
  • Cleaned up the settings a little bit


  • Added support for PhpRedis TLS connections
  • Added support for timeout, read timeout and password when using PhpRedis cluster
  • Fixed issue with INFO command
  • Fixed object cloning when setting cache keys


  • Added object cloning to in-memory cache
  • Fixed PHP notice related to read_timeout parameter


Please flush the object cache after updating the drop to v1.5.5 to avoid dead keys filling up Redis memory.

  • Removed lowercasing keys
  • Remove scheduled metrics event
  • Fixed Redis version call when using replication


  • Removed metrics


  • Fixed: Call to undefined function get_plugin_data()
  • Fixed: Call to undefined method WP_Object_Cache::redis_version()


  • Added Redis version to diagnostics
  • Added WP_REDIS_DISABLE_BANNERS constant to disable promotions
  • Fixed an issue with redis.replicate_commands()


This plugin turned 5 years today (Nov 14th) and its only fitting to release the business edition today as well.
Redis Cache Pro is a truly reliable, highly optimized and easy to debug rewrite of this plugin for SMBs.

  • Added execution times to actions
  • Added WP_REDIS_VERSION constant
  • Fixed PhpRedis v3 compatibility
  • Fixed an issue with selective flushing
  • Fixed an issue with mb_* functions not existing
  • Replaced Email Address Encoder card with Redis Cache Pro card
  • Gather version metrics for better decision making


Since Predis isn’t maintained any longer, it’s highly recommended to switch over to PhpRedis (the Redis PECL extension).

  • Improved Redis key name builder
  • Added support for PhpRedis serializers
  • Added redis_object_cache_error action
  • Added timeout, read-timeout and retry configuration
  • Added unflushable groups (defaults to ['userlogins'])
  • Fixed passwords not showing in server list


  • Require PHP 5.4 or newer
  • Use pretty print in diagnostics
  • Throw exception if Redis library is missing
  • Fixed cache not flushing for some users
  • Fixed admin issues when WP_REDIS_DISABLED is false


  • Added graceful Redis failures and WP_REDIS_GRACEFUL constant
  • Improved cluster support
  • Added redis_cache_expiration filter
  • Renamed redis_object_cache_get filter to redis_object_cache_get_value


  • Fixed potential fatal error related to wp_suspend_cache_addition()


  • Added support for igbinary
  • Added support for wp_suspend_cache_addition()


  • Fixed WP_REDIS_SHARDS not showing up in server list
  • Fixed WP_REDIS_SHARDS not working when using PECL extension
  • Removed WP_REDIS_SCHEME and WP_REDIS_PATH leftovers


  • Switched from single file Predis version to full library


  • Revert back to single file Predis version


  • Added support for Redis Sentinel
  • Added support for sharing
  • Switched to PHAR version of Predis
  • Improved diagnostics
  • Added $fail_gracefully parameter to WP_Object_Cache::__construct()
  • Always enforce WP_REDIS_MAXTTL
  • Pass $selective and $salt to redis_object_cache_flush action
  • Don’t set WP_CACHE_KEY_SALT constant


  • Added basic diagnostics to admin interface
  • Added WP_REDIS_DISABLED constant to disable cache at runtime
  • Prevent «Invalid plugin header» error
  • Return integer from increment() and decrement() methods
  • Prevent object cache from being instantiated more than once
  • Always separate cache key prefix and group by semicolon
  • Improved performance of build_key()
  • Only apply redis_object_cache_get filter if callbacks have been registered
  • Fixed add_or_replace() to only set cache key if it doesn’t exist
  • Added redis_object_cache_flush action
  • Added redis_object_cache_enable action
  • Added redis_object_cache_disable action
  • Added redis_object_cache_update_dropin action


  • Added WP-CLI support
  • Show host and port unless scheme is unix
  • Updated default global and ignored groups
  • Do a cache flush when activating, deactivating and uninstalling


  • Updated Predis to v1.1.1
  • Added redis_instance() method
  • Added incr() method alias for Batcache compatibility
  • Added redis_object_cache_delete action
  • Use WP_PLUGIN_DIR with WP_CONTENT_DIR as fallback
  • Set password when using a cluster or replication
  • Show Redis client in stats()
  • Change visibility of $cache to public
  • Use old array syntax, just in case


  • Make sure $result is not false in WP_Object_Cache::get()


  • Fixed connection issue


  • New admin interface
  • Added support for wp_cache_get()‘s $force and $found parameter
  • Added support for clustering and replication with Predis


  • UI improvements


  • Added redis_object_cache_set action
  • Added redis_object_cache_get action and filter
  • Prevented duplicated admin status messages
  • Load bundled Predis library only if necessary
  • Load bundled Predis library using WP_CONTENT_DIR constant
  • Updated stats() method output to be uniform with WordPress


  • Added composer.json
  • Added deactivation and uninstall hooks to delete object-cache.php
  • Added local serialization functions for better advanced-cache.php support
  • Updated bundled Predis version to 1.0.3
  • Updated heading structure to be semantic


  • Added Multisite support
  • Moved admin menu under Settings menu
  • Fixed PHP notice in get_redis_client_name()


  • Call select() and optionally auth() if HHVM extension is used


  • Added support for HHVM’s Redis extension
  • Added support for PECL Redis extension
  • Added WP_REDIS_CLIENT constant, to set preferred Redis client
  • Added WP_REDIS_MAXTTL constant, to force expiration of cache keys
  • Improved add_or_replace(), get(), set() and delete() methods
  • Improved admin screen styles
  • Removed all internationalization/localization from drop-in


  • Added «Flush Cache» button
  • Added support for UNIX domain sockets
  • Improved cache object retrieval performance significantly
  • Updated bundled Predis library to version 1.0.1


  • Load plugin translations
  • Hide global admin notices from non-admin users
  • Prevent direct file access to redis-cache.php and admin-page.php
  • Colorize «Disable Object Cache» button
  • Call Predis\Client->connect() to avoid potential uncaught Predis\Connection\ConnectionException


  • Versión inicial