<?php /** * memcached diagnostic tool * * @file * @todo document * @ingroup Maintenance */ /** */ require_once dirname(__FILE__) . '/commandLine.inc'; $mcc = new MWMemcached(array('persistant' => true)); $mcc->set_servers($wgMemCachedServers); # $mcc->set_debug( true ); function mccShowHelp($command) { $commandList = array('get' => 'grabs something', 'getsock' => 'lists sockets', 'set' => 'changes something', 'delete' => 'deletes something', 'history' => 'show command line history', 'server' => 'show current memcached server', 'dumpmcc' => 'shows the whole thing', 'exit' => 'exit mcc', 'quit' => 'exit mcc', 'help' => 'help about a command'); if (!$command) { $command = 'fullhelp'; } if ($command === 'fullhelp') { $max_cmd_len = max(array_map('strlen', array_keys($commandList))); foreach ($commandList as $cmd => $desc) { printf("%-{$max_cmd_len}s: %s\n", $cmd, $desc); } } elseif (isset($commandList[$command])) { print "{$command}: {$commandList[$command]}\n"; } else { print "{$command}: command does not exist or no help for it\n"; } }
$debug = isset($options['debug']); $help = isset($options['help']); $cache = isset($options['cache']) ? $options['cache'] : null; if ($help) { mccShowUsage(); exit(0); } $mcc = new MWMemcached(array('persistent' => true, 'debug' => $debug)); 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]['servers'])) { $mcc->set_servers($wgObjectCaches[$wgMainCacheType]['servers']); } else { print "MediaWiki isn't configured for Memcached usage\n"; exit(1); } /** * Show this command line tool usage. */ function mccShowUsage() { echo <<<EOF Usage: \tmcc.php [--debug] \tmcc.php --help