58 $objectCaches = $config->get( MainConfigNames::ObjectCaches );
59 $mainCacheType = $config->get( MainConfigNames::MainCacheType );
62 if ( !isset( $objectCaches[$cache] ) ) {
63 $this->
fatalError(
"MediaWiki isn't configured with a cache named '$cache'" );
65 $servers = $objectCaches[$cache][
'servers'];
67 $mcc->set_servers( $config->get( MainConfigNames::MemCachedServers ) );
68 } elseif ( isset( $objectCaches[$mainCacheType][
'servers'] ) ) {
69 $mcc->set_servers( $objectCaches[$mainCacheType][
'servers'] );
71 $this->
fatalError(
"MediaWiki isn't configured for Memcached usage" );
79 if ( $line ===
false ) {
83 $args = explode(
' ', $line );
84 $command = array_shift( $args );
90 print $this->mccGetHelp( array_shift( $args ) );
95 if ( array_key_exists( 1, $args ) ) {
98 print
"Getting {$args[0]}[$sub]\n";
99 $res = $mcc->get( $args[0] );
100 if ( array_key_exists( 1, $args ) ) {
101 $res = $res[$args[1]];
103 if ( $res ===
false ) {
104 # print 'Error: ' . $mcc->error_string() . "\n";
105 print
"MemCached error\n";
106 } elseif ( is_string( $res ) ) {
114 $res = $mcc->get( $args[0] );
115 $sock = $mcc->get_sock( $args[0] );
120 if ( $mcc->_single_sock !==
null ) {
121 print $mcc->_single_sock .
"\n";
124 $res = $mcc->get( $args[0] );
125 $hv = $mcc->_hashfunc( $args[0] );
126 for ( $i = 0; $i < 3; $i++ ) {
127 print $mcc->_buckets[$hv % $mcc->_bucketcount] .
"\n";
128 $hv += $mcc->_hashfunc( $i . $args[0] );
133 $key = array_shift( $args );
134 if ( $args[0] ==
"#" && is_numeric( $args[1] ) ) {
135 $value = str_repeat(
'*', (
int)$args[1] );
137 $value = implode(
' ', $args );
139 if ( !$mcc->set( $key, $value, 0 ) ) {
140 # print 'Error: ' . $mcc->error_string() . "\n";
141 print
"MemCached error\n";
146 $key = implode(
' ', $args );
147 if ( !$mcc->delete( $key ) ) {
148 # print 'Error: ' . $mcc->error_string() . "\n";
149 print
"MemCached error\n";
154 if ( function_exists(
'readline_list_history' ) ) {
155 foreach ( readline_list_history() as $num => $line ) {
156 print
"$num: $line\n";
159 print
"readline_list_history() not available\n";
178 print
"Bad command\n";
181 if ( function_exists(
'readline_add_history' ) ) {
182 readline_add_history( $line );
206 $max_cmd_len = max( array_map(
'strlen', array_keys( $commandList ) ) );