Code clarity tweak
[lhc/web/wiklou.git] / maintenance / mcc.php
old mode 100755 (executable)
new mode 100644 (file)
index 0d83378..909d7ca
@@ -2,16 +2,15 @@
 /**
  * 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 );
 
@@ -77,7 +76,7 @@ do {
 
        $line = readconsole( '> ' );
        if ($line === false) exit;
-       
+
        $args = explode( ' ', $line );
        $command = array_shift( $args );
 
@@ -89,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]];
@@ -112,7 +115,11 @@ do {
 
                case 'server':
                        $res = $mcc->get( $args[0] );
-                       print $mcc->_buckets[$mcc->_hashfunc( $args[0] ) % $mcc->_bucketcount] . "\n";
+                       $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':
@@ -138,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";
                        }
@@ -168,4 +177,4 @@ do {
        }
 } while ( !$quit );
 
-?>
+