55 $objectCaches = $config->get( MainConfigNames::ObjectCaches );
56 $mainCacheType = $config->get( MainConfigNames::MainCacheType );
59 if ( !isset( $objectCaches[$cache] ) ) {
60 $this->
fatalError(
"MediaWiki isn't configured with a cache named '$cache'" );
62 $servers = $objectCaches[$cache][
'servers'];
64 $mcc->set_servers( $config->get( MainConfigNames::MemCachedServers ) );
65 } elseif ( isset( $objectCaches[$mainCacheType][
'servers'] ) ) {
66 $mcc->set_servers( $objectCaches[$mainCacheType][
'servers'] );
68 $this->
fatalError(
"MediaWiki isn't configured for Memcached usage" );
76 if ( $line ===
false ) {
80 $args = explode(
' ', $line );
81 $command = array_shift( $args );
87 print $this->mccGetHelp( array_shift( $args ) );
92 if ( array_key_exists( 1, $args ) ) {
95 print
"Getting {$args[0]}[$sub]\n";
96 $res = $mcc->get( $args[0] );
97 if ( array_key_exists( 1, $args ) ) {
98 $res = $res[$args[1]];
100 if ( $res ===
false ) {
101 # print 'Error: ' . $mcc->error_string() . "\n";
102 print
"MemCached error\n";
103 } elseif ( is_string( $res ) ) {
111 $res = $mcc->get( $args[0] );
112 $sock = $mcc->get_sock( $args[0] );
117 if ( $mcc->_single_sock !==
null ) {
118 print $mcc->_single_sock .
"\n";
121 $res = $mcc->get( $args[0] );
122 $hv = $mcc->_hashfunc( $args[0] );
123 for ( $i = 0; $i < 3; $i++ ) {
124 print $mcc->_buckets[$hv % $mcc->_bucketcount] .
"\n";
125 $hv += $mcc->_hashfunc( $i . $args[0] );
130 $key = array_shift( $args );
131 if ( $args[0] ==
"#" && is_numeric( $args[1] ) ) {
132 $value = str_repeat(
'*', (
int)$args[1] );
134 $value = implode(
' ', $args );
136 if ( !$mcc->set( $key, $value, 0 ) ) {
137 # print 'Error: ' . $mcc->error_string() . "\n";
138 print
"MemCached error\n";
143 $key = implode(
' ', $args );
144 if ( !$mcc->delete( $key ) ) {
145 # print 'Error: ' . $mcc->error_string() . "\n";
146 print
"MemCached error\n";
151 if ( function_exists(
'readline_list_history' ) ) {
152 foreach ( readline_list_history() as $num => $line ) {
153 print
"$num: $line\n";
156 print
"readline_list_history() not available\n";
175 print
"Bad command\n";
178 if ( function_exists(
'readline_add_history' ) ) {
179 readline_add_history( $line );
203 $max_cmd_len = max( array_map(
'strlen', array_keys( $commandList ) ) );