2 require_once( "../includes/DefaultSettings.php" );
3 require_once( "../LocalSettings.php" );
4 require_once( "../includes/MemCachedClient.inc.php" );
6 $mcc = new MemCachedClient();
7 $mcc->set_servers( $wgMemCachedServers );
12 $line = readconsole( "> " );
13 $args = explode( " ", $line );
14 $command = array_shift( $args );
17 print "Getting {$args[0]}[{$args[1]}]\n";
18 $res = $mcc->get( $args[0] );
19 if ( array_key_exists( 1, $args ) ) {
20 $res = $res[$args[1]];
22 if ( $res === false ) {
23 print 'Error: ' . $mcc->error_string() . "\n";
24 } elseif ( is_string( $res ) ) {
31 $key = array_shift( $args );
32 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
33 $value = str_repeat( "*", $args[1] );
35 $value = implode( " ", $args );
37 if ( !$mcc->set( $key, $value, 0 ) ) {
38 print 'Error: ' . $mcc->error_string() . "\n";
42 $key = implode( " ", $args );
43 if ( !$mcc->delete( $key ) ) {
44 print 'Error: ' . $mcc->error_string() . "\n";
55 print "Bad command\n";
58 if ( function_exists( "readline_add_history" ) ) {
59 readline_add_history( $line );
64 function readconsole( $prompt = "" ) {
65 if ( function_exists( "readline" ) ) {
66 return readline( $prompt );
69 $fp = fopen( "php://stdin", "r" );
70 $resp = trim( fgets( $fp, 1024 ) );