2 /*require_once( "../includes/DefaultSettings.php" );
3 require_once( "../LocalSettings.php" );
4 require_once( "../includes/MemCachedClient.inc.php" );*/
7 require_once( "liveCmdLine.inc" );
9 $mcc = new memcached( array('persistant' => true) );
10 $mcc->set_servers( $wgMemCachedServers );
11 $mcc->set_debug( true );
16 $line = readconsole( "> " );
17 $args = explode( " ", $line );
18 $command = array_shift( $args );
21 print "Getting {$args[0]}[{$args[1]}]\n";
22 $res = $mcc->get( $args[0] );
23 if ( array_key_exists( 1, $args ) ) {
24 $res = $res[$args[1]];
26 if ( $res === false ) {
27 #print 'Error: ' . $mcc->error_string() . "\n";
28 print "MemCached error\n";
29 } elseif ( is_string( $res ) ) {
36 $key = array_shift( $args );
37 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
38 $value = str_repeat( "*", $args[1] );
40 $value = implode( " ", $args );
42 if ( !$mcc->set( $key, $value, 0 ) ) {
43 #print 'Error: ' . $mcc->error_string() . "\n";
44 print "MemCached error\n";
48 $key = implode( " ", $args );
49 if ( !$mcc->delete( $key ) ) {
50 #print 'Error: ' . $mcc->error_string() . "\n";
51 print "MemCached error\n";
62 print "Bad command\n";
65 if ( function_exists( "readline_add_history" ) ) {
66 readline_add_history( $line );
71 function readconsole( $prompt = "" ) {
72 if ( function_exists( "readline" ) ) {
73 return readline( $prompt );
76 $fp = fopen( "php://stdin", "r" );
77 $resp = trim( fgets( $fp, 1024 ) );