3 * memcached diagnostic tool
7 * @subpackage Maintenance
11 require_once( "commandLine.inc" );
12 require_once("memcached-client.php");
14 $mcc = new memcached( array('persistant' => true, 'debug' => true) );
15 $mcc->set_servers( $wgMemCachedServers );
16 $mcc->set_debug( true );
21 $line = readconsole( "> " );
22 if ($line === false) exit;
23 $args = explode( " ", $line );
24 $command = array_shift( $args );
27 print "Getting {$args[0]}[{$args[1]}]\n";
28 $res = $mcc->get( $args[0] );
29 if ( array_key_exists( 1, $args ) ) {
30 $res = $res[$args[1]];
32 if ( $res === false ) {
33 #print 'Error: ' . $mcc->error_string() . "\n";
34 print "MemCached error\n";
35 } elseif ( is_string( $res ) ) {
42 $res = $mcc->get( $args[0] );
43 $sock = $mcc->get_sock( $args[0] );
47 $key = array_shift( $args );
48 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
49 $value = str_repeat( "*", $args[1] );
51 $value = implode( " ", $args );
53 if ( !$mcc->set( $key, $value, 0 ) ) {
54 #print 'Error: ' . $mcc->error_string() . "\n";
55 print "MemCached error\n";
59 $key = implode( " ", $args );
60 if ( !$mcc->delete( $key ) ) {
61 #print 'Error: ' . $mcc->error_string() . "\n";
62 print "MemCached error\n";
77 print "Bad command\n";
80 if ( function_exists( "readline_add_history" ) ) {
81 readline_add_history( $line );