Database::setIgnoreErrors() doesn't seem to exist anymore. Switched to
[lhc/web/wiklou.git] / maintenance / mcc.php
1 <?php
2
3 require_once( "commandLine.inc" );
4
5 $mcc = new memcached( array('persistant' => true) );
6 $mcc->set_servers( $wgMemCachedServers );
7 $mcc->set_debug( true );
8
9 do {
10 $bad = false;
11 $quit = false;
12 $line = readconsole( "> " );
13 $args = explode( " ", $line );
14 $command = array_shift( $args );
15 switch ( $command ) {
16 case "get":
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]];
21 }
22 if ( $res === false ) {
23 #print 'Error: ' . $mcc->error_string() . "\n";
24 print "MemCached error\n";
25 } elseif ( is_string( $res ) ) {
26 print "$res\n";
27 } else {
28 var_dump( $res );
29 }
30 break;
31 case "set":
32 $key = array_shift( $args );
33 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
34 $value = str_repeat( "*", $args[1] );
35 } else {
36 $value = implode( " ", $args );
37 }
38 if ( !$mcc->set( $key, $value, 0 ) ) {
39 #print 'Error: ' . $mcc->error_string() . "\n";
40 print "MemCached error\n";
41 }
42 break;
43 case "delete":
44 $key = implode( " ", $args );
45 if ( !$mcc->delete( $key ) ) {
46 #print 'Error: ' . $mcc->error_string() . "\n";
47 print "MemCached error\n";
48 }
49 break;
50 case "quit":
51 $quit = true;
52 break;
53 default:
54 $bad = true;
55 }
56 if ( $bad ) {
57 if ( $command ) {
58 print "Bad command\n";
59 }
60 } else {
61 if ( function_exists( "readline_add_history" ) ) {
62 readline_add_history( $line );
63 }
64 }
65 } while ( !$quit );
66
67 ?>
68