44 $objectCaches = $config->get( MainConfigNames::ObjectCaches );
45 $mainCacheType = $config->get( MainConfigNames::MainCacheType );
48 if ( !isset( $objectCaches[$cache] ) ) {
49 $this->
fatalError(
"MediaWiki isn't configured with a cache named '$cache'" );
51 $servers = $objectCaches[$cache][
'servers'];
53 $mcc->set_servers( $config->get( MainConfigNames::MemCachedServers ) );
54 } elseif ( isset( $objectCaches[$mainCacheType][
'servers'] ) ) {
55 $mcc->set_servers( $objectCaches[$mainCacheType][
'servers'] );
57 $this->
fatalError(
"MediaWiki isn't configured for Memcached usage" );
65 if ( $line ===
false ) {
69 $args = explode(
' ', $line );
70 $command = array_shift( $args );
76 print $this->mccGetHelp( array_shift( $args ) );
81 if ( array_key_exists( 1, $args ) ) {
84 print
"Getting {$args[0]}[$sub]\n";
85 $res = $mcc->get( $args[0] );
86 if ( array_key_exists( 1, $args ) ) {
87 $res = $res[$args[1]];
89 if ( $res ===
false ) {
90 # print 'Error: ' . $mcc->error_string() . "\n";
91 print
"MemCached error\n";
92 } elseif ( is_string( $res ) ) {
100 $res = $mcc->get( $args[0] );
101 $sock = $mcc->get_sock( $args[0] );
106 if ( $mcc->_single_sock !==
null ) {
107 print $mcc->_single_sock .
"\n";
110 $res = $mcc->get( $args[0] );
111 $hv = $mcc->_hashfunc( $args[0] );
112 for ( $i = 0; $i < 3; $i++ ) {
113 print $mcc->_buckets[$hv % $mcc->_bucketcount] .
"\n";
114 $hv += $mcc->_hashfunc( $i . $args[0] );
119 $key = array_shift( $args );
120 if ( $args[0] ==
"#" && is_numeric( $args[1] ) ) {
121 $value = str_repeat(
'*', (
int)$args[1] );
123 $value = implode(
' ', $args );
125 if ( !$mcc->set( $key, $value, 0 ) ) {
126 # print 'Error: ' . $mcc->error_string() . "\n";
127 print
"MemCached error\n";
132 $key = implode(
' ', $args );
133 if ( !$mcc->delete( $key ) ) {
134 # print 'Error: ' . $mcc->error_string() . "\n";
135 print
"MemCached error\n";
140 if ( function_exists(
'readline_list_history' ) ) {
141 foreach ( readline_list_history() as $num => $line ) {
142 print
"$num: $line\n";
145 print
"readline_list_history() not available\n";
164 print
"Bad command\n";
167 if ( function_exists(
'readline_add_history' ) ) {
168 readline_add_history( $line );
195 $max_cmd_len = max( array_map(
'strlen', array_keys( $commandList ) ) );