3 * memcached diagnostic tool
7 * @subpackage Maintenance
11 require_once( "commandLine.inc" );
13 $mcc = new memcached( array('persistant' => true) );
14 $mcc->set_servers( $wgMemCachedServers );
15 $mcc->set_debug( true );
20 $line = readconsole( "> " );
21 $args = explode( " ", $line );
22 $command = array_shift( $args );
25 print "Getting {$args[0]}[{$args[1]}]\n";
26 $res = $mcc->get( $args[0] );
27 if ( array_key_exists( 1, $args ) ) {
28 $res = $res[$args[1]];
30 if ( $res === false ) {
31 #print 'Error: ' . $mcc->error_string() . "\n";
32 print "MemCached error\n";
33 } elseif ( is_string( $res ) ) {
40 $res = $mcc->get( $args[0] );
41 $sock = $mcc->get_sock( $args[0] );
45 $key = array_shift( $args );
46 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
47 $value = str_repeat( "*", $args[1] );
49 $value = implode( " ", $args );
51 if ( !$mcc->set( $key, $value, 0 ) ) {
52 #print 'Error: ' . $mcc->error_string() . "\n";
53 print "MemCached error\n";
57 $key = implode( " ", $args );
58 if ( !$mcc->delete( $key ) ) {
59 #print 'Error: ' . $mcc->error_string() . "\n";
60 print "MemCached error\n";
75 print "Bad command\n";
78 if ( function_exists( "readline_add_history" ) ) {
79 readline_add_history( $line );