From: Aaron Schulz Date: Fri, 15 Mar 2013 06:09:24 +0000 (-0700) Subject: Added a --cache option to mctest.php and mcc.php. X-Git-Tag: 1.31.0-rc.0~20334^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=cef71790579b6e4a6394c9cc124860f680fffa5b;p=lhc%2Fweb%2Fwiklou.git Added a --cache option to mctest.php and mcc.php. * This lets the server list used be that of different object caches. Change-Id: I88039370affec6e431c931337d220f7472f6eaeb --- diff --git a/maintenance/mcc.php b/maintenance/mcc.php index 4e0f291b73..6ff8a176d0 100644 --- a/maintenance/mcc.php +++ b/maintenance/mcc.php @@ -25,10 +25,13 @@ /** */ require_once( __DIR__ . '/commandLine.inc' ); -$debug = in_array( '--debug', $argv ); -$help = in_array( '--help', $argv ); +$options = getopt( '', array( 'debug', 'help', 'cache:' ) ); -if( $help ) { +$debug = isset( $options['debug'] ); +$help = isset( $options['help'] ); +$cache = isset( $options['cache'] ) ? $options['cache'] : null; + +if ( $help ) { mccShowUsage(); exit( 0 ); } @@ -37,9 +40,15 @@ $mcc = new MWMemcached( array( 'debug' => $debug, ) ); -if ( $wgMainCacheType === CACHE_MEMCACHED ) { +if ( $cache ) { + if ( !isset( $wgObjectCaches[$cache] ) ) { + print "MediaWiki isn't configured with a cache named '$cache'"; + exit( 1 ); + } + $servers = $wgObjectCaches[$cache]['servers']; +} elseif ( $wgMainCacheType === CACHE_MEMCACHED ) { $mcc->set_servers( $wgMemCachedServers ); -} elseif( isset( $wgObjectCaches[$wgMainCacheType] ) ) { +} elseif( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) { $mcc->set_servers( $wgObjectCaches[$wgMainCacheType]['servers'] ); } else { print "MediaWiki isn't configured for Memcached usage\n"; diff --git a/maintenance/mctest.php b/maintenance/mctest.php index 42461c5444..469feca2fb 100644 --- a/maintenance/mctest.php +++ b/maintenance/mctest.php @@ -36,19 +36,26 @@ class mcTest extends Maintenance { $this->mDescription = "Makes several 'set', 'incr' and 'get' requests on every" . " memcached server and shows a report"; $this->addOption( 'i', 'Number of iterations', false, true ); + $this->addOption( 'cache', 'Use servers from this $wgObjectCaches store', false, true ); $this->addArg( 'server[:port]', 'Memcached server to test, with optional port', false ); } public function execute() { global $wgMainCacheType, $wgMemCachedTimeout, $wgObjectCaches; + $cache = $this->getOption( 'cache' ); $iterations = $this->getOption( 'i', 100 ); - if ( $this->hasArg() ) { + if ( $cache ) { + if ( !isset( $wgObjectCaches[$cache] ) ) { + $this->error( "MediaWiki isn't configured with a cache named '$cache'", 1 ); + } + $servers = $wgObjectCaches[$cache]['servers']; + } elseif ( $this->hasArg() ) { $servers = array( $this->getArg() ); } elseif ( $wgMainCacheType === CACHE_MEMCACHED ) { global $wgMemCachedServers; $servers = $wgMemCachedServers ; - } elseif( isset( $wgObjectCaches[$wgMainCacheType] ) ) { + } elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) { $servers = $wgObjectCaches[$wgMainCacheType]['servers']; } else { $this->error( "MediaWiki isn't configured for Memcached usage", 1 );