implement "action=render"
[lhc/web/wiklou.git] / maintenance / mcc.php
1 <?php
2 /**
3 * memcached diagnostic tool
4 *
5 * @todo document
6 * @package MediaWiki
7 * @subpackage Maintenance
8 */
9
10 /** */
11 require_once( "commandLine.inc" );
12 require_once("memcached-client.php");
13
14 $mcc = new memcached( array('persistant' => true) );
15 $mcc->set_servers( $wgMemCachedServers );
16 $mcc->set_debug( true );
17
18 do {
19 $bad = false;
20 $quit = false;
21 $line = readconsole( "> " );
22 $args = explode( " ", $line );
23 $command = array_shift( $args );
24 switch ( $command ) {
25 case "get":
26 print "Getting {$args[0]}[{$args[1]}]\n";
27 $res = $mcc->get( $args[0] );
28 if ( array_key_exists( 1, $args ) ) {
29 $res = $res[$args[1]];
30 }
31 if ( $res === false ) {
32 #print 'Error: ' . $mcc->error_string() . "\n";
33 print "MemCached error\n";
34 } elseif ( is_string( $res ) ) {
35 print "$res\n";
36 } else {
37 var_dump( $res );
38 }
39 break;
40 case "getsock":
41 $res = $mcc->get( $args[0] );
42 $sock = $mcc->get_sock( $args[0] );
43 var_dump( $sock );
44 break;
45 case "set":
46 $key = array_shift( $args );
47 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
48 $value = str_repeat( "*", $args[1] );
49 } else {
50 $value = implode( " ", $args );
51 }
52 if ( !$mcc->set( $key, $value, 0 ) ) {
53 #print 'Error: ' . $mcc->error_string() . "\n";
54 print "MemCached error\n";
55 }
56 break;
57 case "delete":
58 $key = implode( " ", $args );
59 if ( !$mcc->delete( $key ) ) {
60 #print 'Error: ' . $mcc->error_string() . "\n";
61 print "MemCached error\n";
62 }
63 break;
64 case "dumpmcc":
65 var_dump( $mcc );
66 break;
67 case "quit":
68 case "exit":
69 $quit = true;
70 break;
71 default:
72 $bad = true;
73 }
74 if ( $bad ) {
75 if ( $command ) {
76 print "Bad command\n";
77 }
78 } else {
79 if ( function_exists( "readline_add_history" ) ) {
80 readline_add_history( $line );
81 }
82 }
83 } while ( !$quit );
84
85 ?>