Code clarity tweak
[lhc/web/wiklou.git] / maintenance / mcc.php
old mode 100755 (executable)
new mode 100644 (file)
index 9515737..909d7ca
@@ -2,18 +2,17 @@
 /**
  * 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) {
 
@@ -46,6 +45,10 @@ 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; }
@@ -85,7 +88,11 @@ do {
                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]];
@@ -106,6 +113,15 @@ do {
                        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] ) ) {
@@ -129,7 +145,9 @@ do {
 
                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";
                        }
@@ -159,4 +177,4 @@ do {
        }
 } while ( !$quit );
 
-?>
+