Roots Discourse

Configuring Object Cache w/ Memcache

I know trellis currently ships with Memcache installed, but I don’t believe at this point there’s anything built-in to Bedrock, Trellis, or Sage that takes advantage of it. I’m attempting to get my site working with Object caching. I know Trellis ships with a microcache for full pages, but I was wondering if anyone has any experience/recommendations for getting this working. What advanced-cache.php are you using? And what issues have you run into and how have you solved them?

It actually get weirder… it appears, after adding the object-cache.php file, the site gets slower. I have no idea why. I’m using memcached-redux + batcache for advanced-cache.php

What does batcache debug comments say?

Object cache doesn’t limited to page caches(batcache).
It’s used in transients api, advanced-post-cache, fragment-cache and it’s up to plugin authors to use wp_cache_get kind of things.

I am happily using trellis + bedrock with these plugins without issues:

  • batcache
  • advanced-post-cache
  • wp-memcached <-- requires a changes in trellis tasks
  • Sunny <-- disclaimer: i wrote this

Issue turned out to be a weird one. I have a plugin that’s using transients that had a lot of data saved in there. When the options was being loaded, it was attempting to save it into the cache, but it was too big, so it never got saved into the cache. So every time an option was needed, it would go to the cache, not find it, and query it from the db, attempt to save the results, and fail. Over. And Over. And Over. So page loads were taking a long time, because it was doing a very heavy query over and over.

So I cleared the transients from my db, and now everything is working fine. Page load time are ~1s again, and I am happy. I have batcache, object caching, and even nginx caching properly configured (although I probably don’t need all of that, it’s nice to know it works).

That said, advanced-post-cache seems interesting. Will definitely take a look at that. Thanks!

1 Like

What change is required in Trellis tasks for wp-memcached?

memcache => memcached in the PHP extensions.

# roles/memcached/tasks/main.yml
   - memcached
-  - php-memcached
+  - php-memcache

1 Like

I believe we talked about this before but any reason you use memcache over APCu or Redis?

Imo we should remove memcache for those, or at least add them in.

1 Like

Sorry to resurrect 3 years old post.
I’m pretty new to Trellis and Ansible so to me it’s not clear how you setting up trellis for wp-memcached plugin. Would appreciate any help

1 Like