XCache Object Cache Plugin for WordPress 2.5+

Stumble It!

download

Download: xcache-plugin.zip
Version: 0.7d
Updated: August 29, 2008
Size: 1.94 KB

Powered by Drain Hole

This is another one of those articles that will be of interest to a minority of WordPress users. In particular, if you use the XCache PHP opcode cache and Neosmart’s XCache object-cache plugin for WordPress. For those of you who don’t know what the heck I’m babbling about, a PHP opcode cache is a bit of software which helps your web server do less work when turning all your PHP code into web pages that a browser can render. The object-cache plugin is a bit of code added to WordPress which communicates with a caching service in order to reduce the number of database queries it needs to make when building your pages. Together, this helps reduce the CPU load on your web server.

When WordPress 2.5 was released, it introduced some changes to the object cache API. Specifically, it introduced ‘global groups’ and ‘non-persistent groups’, which are just ways for WP to organize and optimize the data it stores in the cache. However, if you didn’t have an updated version of your object-cache.php plugin, you’d start to see some ‘quirks’ in your system. The things I noticed the most were that my comment moderation counts and plugin update counts would not update properly when I flagged comments or upgraded my plugins. I had hoped that Neosmart would update the plugin, but I never saw any news about it, so I ended up just disabling the object-cache on my site.

Then recently, I had to do some work on the memcached version of the object-cache plugin for a client. This inspired me to go ahead and take a look at the code myself, and update the XCache plugin. By looking at the changes to the memcached plugin, I was able to see that it really wasn’t very hard to make similar changes to the XCache plugin.

I’ve sent my changes to the author of the original plugin, but until any official update comes out, you’re welcome to download my changes.

NOTE: this is not a normal WordPress plugin, it does not go in your plugins directory! Install the ‘object-cache.php‘ file directly in your ‘wp-content‘ directory! You must also add the following line to your wp-config.php file, just before the comment that says ’stop editing’:

define(’ENABLE_CACHE’, ‘yes’);This is no longer required in newer versions of WordPress.

For more information, see my previous article, Using the WordPress Object Cache.

UPDATE 2008-09-02: After seeing comments about people getting errors, I took a closer look and found a couple of typos. Version 0.7c should clear those up.

UPDATE 2008-09-11: Updated to version 0.7d, which should do a better job of creating unique keys, even on servers with multiple installations of WP / WPMU. Testers wanted!

Stumble It!

59 Comments

  1. Vahid says:

    Well It was working for for a week then suddenly when one of my site’s went down so did the xcache plugin lol. IT seems to have cached the time when it was down so the site caches a broken version of it. Any ideas? I had to remove it from my other site and only have it on my major site for it to work.

  2. My final comments on the xAccelerator version:

    I fail to see any evidence that it has any measurable impact on the performance of my WP blog. None, zip, zilch.

    After a few days, the blog stops displaying, so I have to restart Apache manually (it’s configured to restart each 24 hours, at midnight, to clear the cache).

    So I don’t see where any of this is taking us anywhere. I’d love to see an improvement, but you’re not there yet.

    Peace,
    Gene

  3. In my case, the server has 4GB of RAM, a dual-core processor and server loads are generally pretty low. Performance is fine without the plugin. It doesn’t change with it installed, only the site stops after a few days, unless I restart Apache.

    My conclusion here is that the plugin has a deleterious effect. I wish it were otherwise.

    Peace,
    Gene

  4. Trent says:

    The strangest thing is that this plugin seems to work fine for me on my WPMU installs, but it always takes away all the links that are specific to WPMU in terms of the overall “site-admin”. It doesn’t affect any blog admin, but it does strip the overall admin from making changes to the overall service without disabling the plugin. Any ideas?

  5. irondele says:

    Downloaded it. Very usefull plugin. Thanks for sharing!

  6. [...] help share my site with others. And I began trying out the Drain Hole plugin (on my post about the XCache object-cache plugin), which is a precursor to the plugin page improvements I mentioned [...]

  7. Ian says:

    Can this be used along with the WP-supercache plugin?

  8. Ian says:

    And I meant to add on a regular wordpress install as well???

  9. [...] help share my site with others. And I began trying out the Drain Hole plugin (on my post about the XCache object-cache plugin), which is a precursor to the plugin page improvements I mentioned [...]