/**
* memcached diagnostic tool
*
+ * @file
* @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @ingroup Maintenance
*/
/** */
-require_once( 'commandLine.inc' );
-require_once( 'memcached-client.php' );
+require_once( dirname(__FILE__) . '/commandLine.inc' );
-$mcc = new memcached( array('persistant' => true, 'debug' => true) );
+$mcc = new MWMemcached( array('persistant' => true/*, 'debug' => true*/) );
$mcc->set_servers( $wgMemCachedServers );
-$mcc->set_debug( true );
+#$mcc->set_debug( true );
function mccShowHelp($command) {
print "history: show command line history\n";
if($onlyone) { break; }
+ case 'server':
+ print "server: show current memcached server\n";
+ if($onlyone) { break; }
+
case 'dumpmcc':
print "dumpmcc: shows the whole thing\n";
if($onlyone) { break; }
break;
case 'get':
- print "Getting {$args[0]}[{$args[1]}]\n";
+ $sub = '';
+ if ( array_key_exists( 1, $args ) ) {
+ $sub = $args[1];
+ }
+ print "Getting {$args[0]}[$sub]\n";
$res = $mcc->get( $args[0] );
if ( array_key_exists( 1, $args ) ) {
$res = $res[$args[1]];
var_dump( $sock );
break;
+ case 'server':
+ $res = $mcc->get( $args[0] );
+ $hv = $mcc->_hashfunc( $args[0] );
+ for ( $i = 0; $i < 3; $i++ ) {
+ print $mcc->_buckets[$hv % $mcc->_bucketcount] . "\n";
+ $hv += $mcc->_hashfunc( $i . $args[0] );
+ }
+ break;
+
case 'set':
$key = array_shift( $args );
if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
case 'history':
if ( function_exists( 'readline_list_history' ) ) {
- print_r(readline_list_history());
+ foreach( readline_list_history() as $num => $line) {
+ print "$num: $line\n";
+ }
} else {
print "readline_list_history() not available\n";
}
}
} while ( !$quit );
-?>
+