Last modified: 2010-05-15 15:41:19 UTC
On lines 63 and 65 of ObjectCache.php, inside the "if ($type == CACHE_MEMCACHED).." statement, on lines 63 and 65: $wgCaches[CACHE_DB] = new MemCachedClientforWiki(...) $cache =& $wgCaches[CACHE_DB]; it seems like CACHE_DB should be changed to CACHE_MEMCACHED Also, would it make sense to add some instructions in docs/memcached to tell people that they should also set the following if they're using memcached? $wgMainCacheType = CACHE_MEMCACHED
Also, I think the $cache =& $wgCaches[CACHE_MEMCACHED] should go outside the IF statement. In summary, I think the last lines of the IF statement should be $wgCaches[CACHE_MEMCACHED] = new MemCachedClientforWiki( array('persistant' => $wgMemCachedPersistent, 'compress_threshold' => 1500 ) ); $wgCaches[CACHE_MEMCACHED]->set_servers( $wgMemCachedServers ); $wgCaches[CACHE_MEMCACHED]->set_debug( $wgMemCachedDebug ); } $cache =& $wgCaches[CACHE_MEMCACHED]; } elseif ($type == CACHE_ACCEL) {
One additional thing: When the key to store contains a space, the memcached process returns a CLIENT_ERROR because its keys can't contain spaces. Does the MemCachedClientforWiki class in ObjectCache.php need to override the various get/set functions and convert spaces in keys to underscores before passing them to memcached? Would that work? Or would it need to convert spaces in keys to a magic string like '__SPACE__'? Is the main wikipedia site using memcached, or one of the other cache alternatives?
Keys cannot contain spaces, so that's user error. Wikipedia uses memcached.
Thanks for the reply. It seems like there are instances where the mediawiki software tries to inject keys with spaces, in particular keys of the form "wikidb:messages:message text". When I go to Special:Upload for example it tries to inject a key for each of the possible license types, and many of them contain spaces.
I've reverted r16928 as this causes the objectcache table to be used instead of memcached, grinding Wikimedia's servers to a halt.
I looked at the diff -- looks good. I think you may also need to add the following line after the if statement: if ( !array_key_exists( CACHE_MEMCACHED, $wgCaches ) ){ ... } //NEW LINE AFTER IF STATEMENT $cache =& $wgCaches[CACHE_MEMCACHED]; to handle the case when another request for a memcached cache is made but the memcached cache has been set up already. This is similar to what you do for CACHE_DBA and CACHE_DB.
Fixed in r41323