3 require_once( "commandLine.inc" );
5 $mcc = new memcached( array('persistant' => true) );
6 $mcc->set_servers( $wgMemCachedServers );
7 $mcc->set_debug( true );
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 print "MemCached error\n";
25 } elseif ( is_string( $res ) ) {
32 $key = array_shift( $args );
33 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
34 $value = str_repeat( "*", $args[1] );
36 $value = implode( " ", $args );
38 if ( !$mcc->set( $key, $value, 0 ) ) {
39 #print 'Error: ' . $mcc->error_string() . "\n";
40 print "MemCached error\n";
44 $key = implode( " ", $args );
45 if ( !$mcc->delete( $key ) ) {
46 #print 'Error: ' . $mcc->error_string() . "\n";
47 print "MemCached error\n";
58 print "Bad command\n";
61 if ( function_exists( "readline_add_history" ) ) {
62 readline_add_history( $line );