PHPackages                             leocolomb/wp-redis - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. leocolomb/wp-redis

ActiveLibrary[Caching](/categories/caching)

leocolomb/wp-redis
==================

A persistent cache backend for WordPress powered by Redis.

3.2.1(3y ago)207.2k3GPL-3.0-or-laterPHPPHP &gt;=7.1CI passing

Since Dec 16Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/LeoColomb/wp-redis)[ Packagist](https://packagist.org/packages/leocolomb/wp-redis)[ Docs](https://github.com/LeoColomb/wp-redis)[ GitHub Sponsors](https://github.com/LeoColomb)[ Patreon](https://www.patreon.com/LeoColomb)[ RSS](/packages/leocolomb-wp-redis/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (21)Used By (0)

Redis Cache for WordPress
=========================

[](#redis-cache-for-wordpress)

> A persistent cache backend powered by Redis.

[![Build Status](https://github.com/LeoColomb/wp-redis/workflows/PHP%20CI/badge.svg)](https://github.com/LeoColomb/wp-redis/actions?query=workflow%3APHP%20CI)[![Packagist](https://camo.githubusercontent.com/1a9ca758536f1ea825a1964641dee50b63c04a4c39d633994238b7b094088c85/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4c656f436f6c6f6d622f77702d72656469732e737667)](https://packagist.org/packages/LeoColomb/wp-redis)

Features
--------

[](#features)

- Enables the two cache wrappers for WordPress
    - Object Cache ([`object-cache.php`](dropins/object-cache.php))
    - Advanced Page Cache ([`advanced-cache.php`](dropins/advanced-cache.php))
- Adds handy [WP-CLI](https://wp-cli.org/) commands
    - `wp redis status`: Show the Redis cache status and (when possible) client.
    - `wp redis flush`: Flush the Redis cache, clear all data.
- Supports major PHP Redis drivers
    - [Predis](https://github.com/nrk/predis/)
    - [PhpRedis (PECL)](https://github.com/phpredis/phpredis)
- Supports replication and clustering
- Targets modern software stacks

Installation
------------

[](#installation)

- Prepare your Composer file by adding custom paths ([more info](https://github.com/Koodimonni/Composer-Dropin-Installer#readme))

    ```
    {
      "extra": {
        "dropin-paths": {
          "htdocs/wp-content/": [
            "package:leocolomb/wp-redis:dropins/object-cache.php",
            "package:leocolomb/wp-redis:dropins/advanced-cache.php"
          ]
        }
      }
    }
    ```
- Require the package in your Composer-managed WordPress instance

    ```
    $ composer require leocolomb/wp-redis
    ```

Configuration
-------------

[](#configuration)

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

### Connection

[](#connection)

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

Constant nameDefault valueDescription`WP_REDIS_CLIENT`*not set*Specifies the client used to communicate with Redis. Supports `pecl` and `predis`.`WP_REDIS_SCHEME``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``127.0.0.1`IP or hostname of the target server. This is ignored when connecting to Redis using UNIX domain sockets.`WP_REDIS_PORT``6379`TCP/IP port of the target server. This is ignored when connecting to Redis using UNIX domain sockets.`WP_REDIS_PATH`*not set*Path of the UNIX domain socket file used when connecting to Redis using UNIX domain sockets.`WP_REDIS_DATABASE``0`Accepts a numeric value that is used to automatically select a logical database with the `SELECT` command.`WP_REDIS_PASSWORD`*not set*Accepts a value used to authenticate with a Redis server protected by password with the `AUTH` command.### Parameters

[](#parameters)

Constant nameDefault valueDescription`WP_CACHE_KEY_SALT`*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_MAXTTL`*not set*Set maximum time-to-live (in seconds) for cache keys with an expiration time of `0`.`WP_REDIS_GLOBAL_GROUPS``['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``['counts', 'plugins']`Set the cache groups that should not be cached in Redis.`WP_REDIS_IGBINARY`*not set*Set to `true` to enable the [igbinary](https://github.com/igbinary/igbinary) serializer.### Page cache

[](#page-cache)

Constant nameDefault valueDescription`WP_CACHE``false`Set to `true` to enable advanced page caching. If not set, the Redis page cache will not be used.`WP_REDIS_TIMES``2`Only cache a page after it is accessed this many times.`WP_REDIS_SECONDS``120`Only cache a page if it is accessed `$times` in this many seconds. Set to zero to ignore this and use cache immediately.`WP_REDIS_MAXAGE``300`Expire cache items aged this many seconds. Set to zero to disable cache.`WP_REDIS_GROUP``'redis-cache'`Name of object cache group used for page cache.`WP_REDIS_UNIQUE``[]`If you conditionally serve different content, put the variable values here using the `add_variant()` method.`WP_REDIS_HEADERS``[]`Add headers here as `name => value` or `name => [values]`. These will be sent with every response from the cache.`WP_REDIS_UNCACHED_HEADERS``['transfer-encoding']`These headers will never be cached. (Use lower case only!)`WP_REDIS_CACHE_CONTROL``true`Set to `false` to disable `Last-Modified` and `Cache-Control` headers.`WP_REDIS_USE_STALE``true`Is it ok to return stale cached response when updating the cache?`WP_REDIS_NOSKIP_COOKIES``['wordpress_test_cookie']`Names of cookies - if they exist and the cache would normally be bypassed, don't bypass it.Replication &amp; Clustering
----------------------------

[](#replication--clustering)

To use Replication and Clustering, make sure your server is running PHP7, your setup is using Predis to connect to Redis and you consulted the [Predis documentation](https://github.com/nrk/predis).

For replication use the `WP_REDIS_SERVERS` constant and for clustering the `WP_REDIS_CLUSTER` constant. You can use a named array or an URI string to specify the parameters.

For authentication use the `WP_REDIS_PASSWORD` constant.

### Master-Slave Replication

[](#master-slave-replication)

```
define('WP_REDIS_SERVERS', [
    'tcp://127.0.0.1:6379?database=15&alias=master',
    'tcp://127.0.0.2:6379?database=15&alias=slave-01',
]);
```

### Clustering via Client-side Sharding

[](#clustering-via-client-side-sharding)

```
define('WP_REDIS_CLUSTER', [
    'tcp://127.0.0.1:6379?database=15&alias=node-01',
    'tcp://127.0.0.2:6379?database=15&alias=node-02',
]);
```

License
-------

[](#license)

GPL-3.0 © [Léo Colombaro](https://colombaro.fr)

- Eric Mann and Erick Hitter for [Redis Object Cache](https://github.com/ericmann/Redis-Object-Cache)
- Till Krüss for [tillkruss/redis-cache](https://github.com/tillkruss/redis-cache)

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance60

Regular maintenance activity

Popularity28

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 60.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~93 days

Recently: every ~330 days

Total

19

Last Release

1436d ago

Major Versions

1.1.2 → 2.0.02018-12-08

2.0.4 → 3.0.02018-12-09

PHP version history (2 changes)1.1.1PHP &gt;=5.4.0

2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/846943?v=4)[Léo Colombaro](/maintainers/LeoColomb)[@LeoColomb](https://github.com/LeoColomb)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (96 commits)")[![LeoColomb](https://avatars.githubusercontent.com/u/846943?v=4)](https://github.com/LeoColomb "LeoColomb (57 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (2 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (1 commits)")[![joselinarest](https://avatars.githubusercontent.com/u/10585476?v=4)](https://github.com/joselinarest "joselinarest (1 commits)")

---

Tags

cacheredisredis-cachewordpresswordpress-drop-inwordpress-dropinwordpressrediswordpress-dropinwordpress-cachecache-objectcache-pagecache-advanced

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/leocolomb-wp-redis/health.svg)

```
[![Health](https://phpackages.com/badges/leocolomb-wp-redis/health.svg)](https://phpackages.com/packages/leocolomb-wp-redis)
```

###  Alternatives

[rhubarbgroup/redis-cache

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

52999.8k1](/packages/rhubarbgroup-redis-cache)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23617.0k1](/packages/rtcamp-nginx-helper)[devgeniem/redipress

RediPress

3433.3k](/packages/devgeniem-redipress)[ihor/cachalot

Cache a lot in a proper way (APC, XCache, Memcached, Redis, Couchbase)

2528.3k](/packages/ihor-cachalot)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
