3 # memcached diagnostic tool
5 require_once( "commandLine.inc" );
7 $mcc = new memcached( array('persistant' => true) );
8 $mcc->set_servers( $wgMemCachedServers );
9 $mcc->set_debug( true );
14 $line = readconsole( "> " );
15 $args = explode( " ", $line );
16 $command = array_shift( $args );
19 print "Getting {$args[0]}[{$args[1]}]\n";
20 $res = $mcc->get( $args[0] );
21 if ( array_key_exists( 1, $args ) ) {
22 $res = $res[$args[1]];
24 if ( $res === false ) {
25 #print 'Error: ' . $mcc->error_string() . "\n";
26 print "MemCached error\n";
27 } elseif ( is_string( $res ) ) {
34 $key = array_shift( $args );
35 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
36 $value = str_repeat( "*", $args[1] );
38 $value = implode( " ", $args );
40 if ( !$mcc->set( $key, $value, 0 ) ) {
41 #print 'Error: ' . $mcc->error_string() . "\n";
42 print "MemCached error\n";
46 $key = implode( " ", $args );
47 if ( !$mcc->delete( $key ) ) {
48 #print 'Error: ' . $mcc->error_string() . "\n";
49 print "MemCached error\n";
60 print "Bad command\n";
63 if ( function_exists( "readline_add_history" ) ) {
64 readline_add_history( $line );