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 $key = array_shift( $args );
41 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
42 $value = str_repeat( "*", $args[1] );
44 $value = implode( " ", $args );
46 if ( !$mcc->set( $key, $value, 0 ) ) {
47 #print 'Error: ' . $mcc->error_string() . "\n";
48 print "MemCached error\n";
52 $key = implode( " ", $args );
53 if ( !$mcc->delete( $key ) ) {
54 #print 'Error: ' . $mcc->error_string() . "\n";
55 print "MemCached error\n";
66 print "Bad command\n";
69 if ( function_exists( "readline_add_history" ) ) {
70 readline_add_history( $line );