57 $objectCaches = $config->get( MainConfigNames::ObjectCaches );
58 $mainCacheType = $config->get( MainConfigNames::MainCacheType );
61 if ( !isset( $objectCaches[$cache] ) ) {
62 $this->
fatalError(
"MediaWiki isn't configured with a cache named '$cache'" );
64 $servers = $objectCaches[$cache][
'servers'];
66 $mcc->set_servers( $config->get( MainConfigNames::MemCachedServers ) );
67 } elseif ( isset( $objectCaches[$mainCacheType][
'servers'] ) ) {
68 $mcc->set_servers( $objectCaches[$mainCacheType][
'servers'] );
70 $this->
fatalError(
"MediaWiki isn't configured for Memcached usage" );
78 if ( $line ===
false ) {
82 $args = explode(
' ', $line );
83 $command = array_shift( $args );
89 print $this->mccGetHelp( array_shift( $args ) );
94 if ( array_key_exists( 1, $args ) ) {
97 print
"Getting {$args[0]}[$sub]\n";
98 $res = $mcc->get( $args[0] );
99 if ( array_key_exists( 1, $args ) ) {
100 $res = $res[$args[1]];
102 if ( $res ===
false ) {
103 # print 'Error: ' . $mcc->error_string() . "\n";
104 print
"MemCached error\n";
105 } elseif ( is_string( $res ) ) {
113 $res = $mcc->get( $args[0] );
114 $sock = $mcc->get_sock( $args[0] );
119 if ( $mcc->_single_sock !==
null ) {
120 print $mcc->_single_sock .
"\n";
123 $res = $mcc->get( $args[0] );
124 $hv = $mcc->_hashfunc( $args[0] );
125 for ( $i = 0; $i < 3; $i++ ) {
126 print $mcc->_buckets[$hv % $mcc->_bucketcount] .
"\n";
127 $hv += $mcc->_hashfunc( $i . $args[0] );
132 $key = array_shift( $args );
133 if ( $args[0] ==
"#" && is_numeric( $args[1] ) ) {
134 $value = str_repeat(
'*', (
int)$args[1] );
136 $value = implode(
' ', $args );
138 if ( !$mcc->set( $key, $value, 0 ) ) {
139 # print 'Error: ' . $mcc->error_string() . "\n";
140 print
"MemCached error\n";
145 $key = implode(
' ', $args );
146 if ( !$mcc->delete( $key ) ) {
147 # print 'Error: ' . $mcc->error_string() . "\n";
148 print
"MemCached error\n";
153 if ( function_exists(
'readline_list_history' ) ) {
154 foreach ( readline_list_history() as $num => $line ) {
155 print
"$num: $line\n";
158 print
"readline_list_history() not available\n";
177 print
"Bad command\n";
180 if ( function_exists(
'readline_add_history' ) ) {
181 readline_add_history( $line );
205 $max_cmd_len = max( array_map(
'strlen', array_keys( $commandList ) ) );