Dougal Campbell's geek ramblings

WordPress, web development, and world domination.

XCache Object Cache Plugin for WordPress 2.5+

download

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

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!

About Dougal Campbell

Dougal is a web developer, and a "Developer Emeritus" for the WordPress platform. When he's not coding PHP, Perl, CSS, JavaScript, or whatnot, he spends time with his wife, three children, a dog, and a cat in their Atlanta area home.
This entry was posted in Plugins, Tech, WordPress and tagged , , , , , , , , , , , , . Bookmark the permalink.

70 Responses to XCache Object Cache Plugin for WordPress 2.5+

  1. Pingback: Wordpress APC Object-Cache modifiziert - Projekte, Wordpress

  2. Pingback: WordPress Plugin Releases for 09/03 | Wordpress Blog NL

  3. Pingback: WordPress Plugin Releases for 09/03 | Credise

  4. Pingback: Rauru Blog » Blog Archive » WordPress ? XCache ?????

  5. Pingback: WordPress Wednesday Kick Off | geek ramblings

  6. Pingback: Dougal Campbell: WordPress Wednesday Kick Off | Aslifmbiz Blog

  7. Pingback: Utilizing Object Cache Using xCache | WPVita

  8. Pingback: Server Reconfig

  9. Pingback: How to optimize and speed up Wordpress - Reaper-X

Leave a Reply