fixed discussion namespace
[lhc/web/wiklou.git] / maintenance / mcc.php
index a6b5249..73b03a1 100755 (executable)
@@ -1,15 +1,25 @@
 <?php
-require_once( "../includes/DefaultSettings.php" );
-require_once( "../LocalSettings.php" );
-require_once( "../includes/MemCachedClient.inc.php" );
+/**
+ * memcached diagnostic tool
+ *
+ * @todo document
+ * @package MediaWiki
+ * @subpackage Maintenance
+ */
 
-$mcc = new MemCachedClient();
+/** */
+require_once( "commandLine.inc" );
+require_once("memcached-client.php");
+
+$mcc = new memcached( array('persistant' => true) );
 $mcc->set_servers( $wgMemCachedServers );
+$mcc->set_debug( true );
 
 do {
        $bad = false;
        $quit = false;
        $line = readconsole( "> " );
+       if ($line === false) exit;
        $args = explode( " ", $line );
        $command = array_shift( $args );
        switch ( $command ) {
@@ -20,13 +30,19 @@ do {
                                $res = $res[$args[1]];
                        }
                        if ( $res === false ) {
-                               print 'Error: ' . $mcc->error_string() . "\n";
+                               #print 'Error: ' . $mcc->error_string() . "\n";
+                               print "MemCached error\n";
                        } elseif ( is_string( $res ) ) {
                                print "$res\n";
                        } else {
                                var_dump( $res );
                        }
                        break;
+               case "getsock":
+                       $res = $mcc->get( $args[0] );
+                       $sock = $mcc->get_sock( $args[0] );
+                       var_dump( $sock );
+                       break;
                case "set":
                        $key = array_shift( $args );
                        if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
@@ -35,16 +51,22 @@ do {
                                $value = implode( " ", $args );
                        }
                        if ( !$mcc->set( $key, $value, 0 ) ) {
-                               print 'Error: ' . $mcc->error_string() . "\n";
+                               #print 'Error: ' . $mcc->error_string() . "\n";
+                               print "MemCached error\n";
                        }
                        break;
                case "delete":
                        $key = implode( " ", $args );
                        if ( !$mcc->delete( $key ) ) {
-                               print 'Error: ' . $mcc->error_string() . "\n";
+                               #print 'Error: ' . $mcc->error_string() . "\n";
+                               print "MemCached error\n";
                        }
                        break;                                 
+               case "dumpmcc":
+                       var_dump( $mcc );
+                       break;
                case "quit":
+               case "exit":
                        $quit = true;
                        break;
                default:
@@ -61,19 +83,4 @@ do {
        }
 } while ( !$quit );
 
-function readconsole( $prompt = "" ) {
-       if ( function_exists( "readline" ) ) {
-               return readline( $prompt );
-       } else {
-               print $prompt;
-               $fp = fopen( "php://stdin", "r" );
-               $resp = trim( fgets( $fp, 1024 ) );
-               fclose( $fp );
-               return $resp;
-       }
-}
-
-
-
 ?>
-