API: documentation and cleanup.
[lhc/web/wiklou.git] / maintenance / mcc.php
old mode 100755 (executable)
new mode 100644 (file)
index 9515737..b0302ab
@@ -3,17 +3,16 @@
  * memcached diagnostic tool
  *
  * @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
  */
 
 /** */
 require_once( 'commandLine.inc' );
 require_once( 'memcached-client.php' );
 
-$mcc = new memcached( array('persistant' => true, 'debug' => true) );
+$mcc = new memcached( 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; }
@@ -106,6 +109,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 +141,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";
                        }