| 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!
XCache Object Cache Plugin for WordPress 2.5+Related posts:
- Using the WordPress Object Cache
" I’ve been planning to write up a plugin to serve as an example of using the WordPress Object Cache, but haven’t had time to..." - W3 Total Cache Plugin
" There’s a new WordPress cache plugin in town, and it’s called W3 Total Cache. This plugin is one of the contestants in the 2009..." - WP-Cache fix for Content-Type in feeds
" If you run a busy WordPress site, or even if your site just has a lot of processor-intensive plugins, then you probably already run..." - Text Filter Suite Plugin for WordPress
"Since Talk Like a Pirate Day is only three weeks away, I spent some time this weekend revamping my old Fun Filters hack. The result..." - My first WordPress plugin: HeadMeta
" Mark Pilgrim was in the #wordpress IRC channel earlier, asking if there was some way to add <link> and <meta> tags to the <head>..."















61 Comments
Downloaded it. Very usefull plugin. Thanks for sharing!
Can this be used along with the WP-supercache plugin?
And I meant to add on a regular wordpress install as well???
Just installed 0.7d, and it's working fine with my blog. Thanks.
I know this post is a year old, but it’s the best/most recent plug-in I could find for using xcache with WP. I just installed it for WP 2.8.4 and it appears to be working great. I don’t quite understand how WP recognizes/uses the plug-in just by uploading the file to the wp-contents folder, but I’m glad it does. Thank you for sharing your updated plug-in.
Hi, is this working with wordpress 8.4
thanks.
Hi, i’m using this plugin on WP 2.8.6 and it seems to work very well, lowering query numbers to a 1/3 factor (from about 60 to about 20). But I notice a strance behaviour: admin password is not recognized at all and i must reset it to obtain admin access again. With all other users, there are no problems.
Can someone point me in the right direction to resolve this issue?
Thanx!
Only one note: if I clear cache content fromXcache admin panel, WP admin access works again.
I’ve found the problem. Don’t know why and don’t know where, WP adds “users”,”userlogins”, “usermeta” to the “global_groups” array and so your plugin store those data with an empty prefix . So, when you run multiple WP on multiple virtualhosts on the same machine, you’re not able to have 2 admin user (or users with the same login) accesses cached at the same time. “Global_groups” (necessary on a WPMU installation that shares authentication parametrs between sub-blogs) should be empty in this case.
As a workaround i’ve patched your code from
function wp_cache_add_global_groups( $groups ) {
global $wp_object_cache;
$wp_object_cache->add_global_groups($groups);
}
to
function wp_cache_add_global_groups( $groups ) {
global $wp_object_cache;
return;
//$wp_object_cache->add_global_groups($groups);
}
It resolves my issue but don’t know if this works on a WPMU installation also (as you manually add global groups at WP_Object_Cache object creation.
Hi, I couldn’t find the link to download the plugin it shows “[drain file 16 show default_show]” instead.
Thanks!
Sorry about that. For some reason, the Drain Hole plugin seems to deactivate itself from time to time. Check again, you should see the download link now.
8 Trackbacks