Phpdoc comments and place holder. Part of the subpackage "maintenance", archives...
[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
13 $mcc = new memcached( array('persistant' => true) );
14 $mcc->set_servers( $wgMemCachedServers );
15 $mcc->set_debug( true );
16
17 do {
18 $bad = false;
19 $quit = false;
20 $line = readconsole( "> " );
21 $args = explode( " ", $line );
22 $command = array_shift( $args );
23 switch ( $command ) {
24 case "get":
25 print "Getting {$args[0]}[{$args[1]}]\n";
26 $res = $mcc->get( $args[0] );
27 if ( array_key_exists( 1, $args ) ) {
28 $res = $res[$args[1]];
29 }
30 if ( $res === false ) {
31 #print 'Error: ' . $mcc->error_string() . "\n";
32 print "MemCached error\n";
33 } elseif ( is_string( $res ) ) {
34 print "$res\n";
35 } else {
36 var_dump( $res );
37 }
38 break;
39 case "set":
40 $key = array_shift( $args );
41 if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
42 $value = str_repeat( "*", $args[1] );
43 } else {
44 $value = implode( " ", $args );
45 }
46 if ( !$mcc->set( $key, $value, 0 ) ) {
47 #print 'Error: ' . $mcc->error_string() . "\n";
48 print "MemCached error\n";
49 }
50 break;
51 case "delete":
52 $key = implode( " ", $args );
53 if ( !$mcc->delete( $key ) ) {
54 #print 'Error: ' . $mcc->error_string() . "\n";
55 print "MemCached error\n";
56 }
57 break;
58 case "quit":
59 $quit = true;
60 break;
61 default:
62 $bad = true;
63 }
64 if ( $bad ) {
65 if ( $command ) {
66 print "Bad command\n";
67 }
68 } else {
69 if ( function_exists( "readline_add_history" ) ) {
70 readline_add_history( $line );
71 }
72 }
73 } while ( !$quit );
74
75 ?>