# Questions about enabling the object cache using Memcached

**URL:** https://discourse.roots.io/t/questions-about-enabling-the-object-cache-using-memcached/30124
**Category:** trellis
**Created:** 2026-01-19T14:44:32Z
**Posts:** 5

## Post 1 by @Tetrahedrax — 2026-01-19T14:44:32Z

Hello!

So, I decided that for funsies I would set up the next site using Memcached instead of Redis as the object cache provider.

The documentation leaves a lot to be desired though, or maybe (most likely?) this is a skill issue

> **[Redis Object Caching for WordPress in Trellis | Trellis Docs](https://roots.io/trellis/docs/redis/)**
>
> Enable Redis in Trellis for WordPress object caching. Improve site performance by caching database queries and reducing load on MySQL database servers.

So I’ve added this to the development/wordpress\_sites.yml:

```
object_cache:
    enabled: true
    provider: memcached 
    database: 0
```

And I’ve installed the suggested plugin with  
`composer require wpackagist-plugin/memcached`

Now to the part where I get confused.  
The documentation says:

> The plugin typically auto-activates when it detects Memcached is available.

Is this an actual thing? Can a plugin auto-activate?

More importantly, when I try to activate the plugin manually I get this error:

`Cannot redeclare function wp_cache_add()`

Now according to the plugin’s site this is because it requires a very manual installation process:

> 1. Install [memcached](http://danga.com/memcached) on at least one server. Note the connection info. The default is `127.0.0.1:11211`.
> 2. Install the [PECL memcache extension](http://pecl.php.net/package/memcache)
> 3. Copy object-cache.php to wp-content
> 4. Add the `WP_CACHE_KEY_SALT` constant to the `wp-config.php`:`phpdefine( 'WP_CACHE_KEY_SALT', '...long random string...' );`

So the question is, what’s the recommended way of using Memcached these days? Is the recommendation a blank “use Redis instead, stoopid!” or is the documentation linking to the wrong plugin or something?

All help, feedback or hate is welcome with open arms.

---

## Post 2 by @TangRufus — 2026-02-18T10:08:12Z

[memcached](https://wordpress.org/plugins/memcached/) is a drop-in plugin.

Unlike regular plugins, it is not meant to be installed under `wp-content/plugins`. Drop-in plugins are meant to be copied to some specific locations. In this case, [`web/app/object-cache.php`](https://github.com/Automattic/wp-memcached/blob/bb3b9f689dd99df66454b93ece34093556dc37f9/readme.txt#L19).

Check the list of drop-in plugins from the source code of [`_get_dropins()`](https://developer.wordpress.org/reference/functions/_get_dropins/#source).

> Can a plugin auto-activate?

It _could_ because WordPress core loads drop-in plugins very early in its lifecycle. Actually, there is no way for you to _deactivate_ drop-in plugins.

> it requires a very manual installation process

~~`composer/installer` [supports drop-in plugins](https://github.com/composer/installers/pull/265). But you might need to update some composer config on your projects.~~ I couldn’t get `composer/installer` to work. Use [`koodimonni/composer-dropin-installer`](https://github.com/Koodimonni/Composer-Dropin-Installer) instead. See [Revise Memcached Object Cache installation instructions by tangrufus · Pull Request #562 · roots/docs · GitHub](https://github.com/roots/docs/pull/562)

---

## Post 3 by @ben — 2026-02-18T15:51:09Z

Thanks for the clarification on that plugin being a drop-in! Just updated the docs

---

## Post 4 by @TangRufus — 2026-02-21T00:21:41Z

> it requires a very manual installation process…

Can you give [Revise Memcached Object Cache installation instructions by tangrufus · Pull Request #562 · roots/docs · GitHub](https://github.com/roots/docs/pull/562) a try please, @Tetrahedrax ?

---

## Post 5 by @Tetrahedrax — 2026-02-23T09:25:55Z

Hello thanks for the help!

I’ve done as follows in an attempt to follow your guide:

1. Set this inside of trellis/group\_vars/development/wordpress\_sites.yml

```
object_cache:
    enabled: true # Enable object caching
    provider: memcached # Use Redis (or memcached)
```

1. Run trellis provision development

2. Add the object-cache.php that you linked here: public/content/object-cache.php (I’m testing this on a Radicle project so maybe the gitignore part should be updated to include Radicle as well?), and run the commands that you’ve included.

3. I visit the site and I get this message:

`Fatal error: Uncaught Error: Class "Memcache" not found in /srv/www/example.se/current/public/content/object-cache.php:849 Stack trace: #0 /srv/www/example.se/current/public/content/object-cache.php(82): WP_Object_Cache->__construct() #1 /srv/www/example.se/current/public/wp/wp-includes/load.php(893): wp_cache_init() #2 /srv/www/example.se/current/public/wp/wp-settings.php(147): wp_start_object_cache() #3 /srv/www/example.se/current/public/wp-config.php(11): require_once('/srv/www/example...') #4 /srv/www/example.se/current/public/wp/wp-load.php(55): require_once('/srv/www/example...') #5 /srv/www/example.se/current/public/wp/wp-admin/admin.php(35): require_once('/srv/www/example...') #6 /srv/www/example.se/current/public/wp/wp-admin/plugins.php(10): require_once('/srv/www/example...') #7 {main} thrown in /srv/www/example.se/current/public/content/object-cache.php on line 849`

1. Pull my hair trying to fix it. I got a lot of hair so that part is fine.

_30 min later_

So the issue is that we’re using Memcache **d** while the plugin is using Memcache.

The solution? Use this plugin instead which uses Memcache **d** :

> <https://github.com/humanmade/wordpress-pecl-memcached-object-cache/blob/628ef994144a8a95defac1a6628cb8b5c079c5ce/object-cache.php>

The moment I added that plugin it started magically working. Feel free trying it on a newly provisioned server and see if it works for you too! If not, I’ll try it myself next week or whenever the reconstructing at work is fully complete. Working without an external screen is hell, man!
