Using memcached with WordPress object cache
I like the web pages to be snappy, including my blog. I found my blog to be bit slow after I moved to WordPress even after performance tuning. After looking around for a solution I came across memcache back-end for WordPress object cache which can be downloaded from here. You have to drop the file object-cache.php into wp-content/. You will have to specify the memcached servers by adding the following lines to wp-config.php.
global $memcached_servers;
$memcached_servers = array('default' => array('127.0.0.1:11211'));
My blog loaded faster than before, it was all good. Afterwards I wanted to install the memcache back-end for WP object cache on my mother’s blog using the same memcached server. I just dropped the wp-config.php file into my mother’s installation of WordPress. That’s when things became awry. My mother’s blog started to redirect to my blog
. After looking at wp-config.php closely it was clear to me it was designed for WordPress MU. However I didn’t want to give up on using memcache with WordPress. Looking even closer I noticed that I can specify the global variable $blog_id and it would be perpended to the memcache object key. I added the following line to wp-config.php in my mother’s WordPress installation in addition to the two lines above and applied this patch.
global $blog_id; $blog_id = 'priyani_mohanjith_net';
That’s it, both my blog and my mother’s blog became fast and it was working without any issues. Hope this helps someone who wants to use the same memcached server with multiple installtions of vanilla WordPress. You cannot use this technique or memcache unless your blog is self hosted on a server where you have full control.
about 9 months ago
Very good
i use in my site with wordpress blogs 
I need put memcached for restart server ?
about 9 months ago
I have problems with multiple blogs in the same server. I user blog_id variable but wp-admin don’t run correct.
I put memcache for carrero.es, herencia.net and decoracion2.com, and /wp-admin/ jump all time to the first access to carrero.es/wp-admin.
I put herencia.net/wp-admin and jump tu carrero.es/wp-admin … why ??
I need help :O now i desactivate memcache
about 9 months ago
Please read the blog post. It’s all about the issue you are having.
about 9 months ago
Remove object-cache.php (just rename it).
about 6 months ago
this seems to work for multiple blogs in wordpress mu or multiple vanilla wordpress…
However this does not work with multiple installations of wordpress mu. Any way to get it to work instead of starting up another memcache server?
about 6 months ago
Mohanjith thank you man its working great!
about 2 months ago
Hey, I found your blog in a new directory of blogs. I dont know how your blog came up, must have been a typo, anyway cool blog, I bookmarked you.
I’m Out!
about 1 month ago
how install the parch?
about 1 month ago
I’m assuming your WordPress directory is named blog. Run the following command in the parent directory.
patch -p0 < object-cachephp.patch
about 1 month ago
thanks, but i need memcache in two domains different in the same server
about 1 month ago
You are not making much sense, do you want to use the same memcache server for two WordPress installations. Please read the post again, it is about using the same memcache server for two WordPress installations, whether it’s on two domains or not is insignificant.
about 1 month ago
ok, but the patch work in this case?
about 1 month ago
dont work with two installation of wordpress, the second installation in the the home page and others show in blank
about 1 month ago
LUis, if you applied the patch properly and made the other configuration changes it will work. I’m using the same memcached server for mohanjith.net/blog and priyani.mohanjith.net/blog and have no such issues. I did have similar issues without the patch.
Can you post your object-cache.php somewhere I can have a look?
about 1 month ago
which makes the patch?
about 1 month ago
I need to make manually changes, which makes the patch changes?