MemCached command line client
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 20 Oct 2003 13:41:43 +0000 (13:41 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 20 Oct 2003 13:41:43 +0000 (13:41 +0000)
maintenance/mcc.php [new file with mode: 0755]

diff --git a/maintenance/mcc.php b/maintenance/mcc.php
new file mode 100755 (executable)
index 0000000..5bf56da
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+include_once( "../includes/DefaultSettings.php" );
+include_once( "../LocalSettings.php" );
+include_once( "../includes/MemCachedClient.inc.php" );
+
+$mcc = new MemCachedClient();
+$mcc->set_servers( $wgMemCachedServers );
+
+do {
+       $bad = false;
+       $quit = false;
+       $line = readline( "> " );
+       $args = explode( " ", $line );
+       $command = array_shift( $args );
+       switch ( $command ) {
+               case "get":
+                       $res = $mcc->get( implode( " ", $args ) );
+                       if ( $res === false ) {
+                               print 'Error: ' . $mcc->error_string() . "\n";
+                       } elseif ( is_string( $res ) ) {
+                               print "$res\n";
+                       } else {
+                               var_dump( $res );
+                       }
+                       break;
+               case "set":
+                       $key = array_shift( $args );
+                       if ( !$mcc->set( $key, implode( " ", $args ), 0 ) ) {
+                               print 'Error: ' . $mcc->error_string() . "\n";
+                       }
+                       break;
+               case "quit":
+                       $quit = true;
+                       break;
+               default:
+                       $bad = true;
+       }
+       if ( $bad ) {
+               if ( $command ) {
+                       print "Bad command\n";
+               }
+       } else {
+               readline_add_history( $line );
+       }
+} while ( !$quit );
+?>
+