29 require_once __DIR__ .
'/CommandLineInc.php';
32 $help = isset( $options[
'help'] );
46 print
"MediaWiki isn't configured with a cache named '$cache'";
55 print
"MediaWiki isn't configured for Memcached usage\n";
68 MemCached Command (mcc) is an interactive command tool that let you interact
72 --debug Set debug mode on the memcached connection.
73 --help This help screen.
79 print str_replace(
"\n",
"\n\t",
mccGetHelp(
false ) );
86 'get' =>
'grabs something',
87 'getsock' =>
'lists sockets',
88 'set' =>
'changes something',
89 'delete' =>
'deletes something',
90 'history' =>
'show command line history',
91 'server' =>
'show current memcached server',
92 'dumpmcc' =>
'shows the whole thing',
95 'help' =>
'help about a command',
101 $max_cmd_len = max( array_map(
'strlen', array_keys( $commandList ) ) );
102 foreach ( $commandList as $cmd => $desc ) {
103 $output .= sprintf(
"%-{$max_cmd_len}s: %s\n", $cmd, $desc );
105 } elseif ( isset( $commandList[
$command] ) ) {
106 $output .=
"$command: $commandList[$command]\n";
108 $output .=
"$command: command does not exist or no help for it\n";
120 if (
$line ===
false ) {
136 if ( array_key_exists( 1,
$args ) ) {
139 print
"Getting {$args[0]}[$sub]\n";
141 if ( array_key_exists( 1,
$args ) ) {
144 if (
$res ===
false ) {
145 # print 'Error: ' . $mcc->error_string() . "\n";
146 print
"MemCached error\n";
147 } elseif ( is_string(
$res ) ) {
161 if (
$mcc->_single_sock !==
null ) {
162 print
$mcc->_single_sock .
"\n";
167 for ( $i = 0; $i < 3; $i++ ) {
168 print
$mcc->_buckets[$hv %
$mcc->_bucketcount] .
"\n";
174 $key = array_shift(
$args );
175 if (
$args[0] ==
"#" && is_numeric(
$args[1] ) ) {
176 $value = str_repeat(
'*', (
int)
$args[1] );
178 $value = implode(
' ',
$args );
180 if ( !
$mcc->set( $key, $value, 0 ) ) {
181 # print 'Error: ' . $mcc->error_string() . "\n";
182 print
"MemCached error\n";
187 $key = implode(
' ',
$args );
188 if ( !
$mcc->delete( $key ) ) {
189 # print 'Error: ' . $mcc->error_string() . "\n";
190 print
"MemCached error\n";
195 if ( function_exists(
'readline_list_history' ) ) {
196 foreach ( readline_list_history() as $num =>
$line ) {
197 print
"$num: $line\n";
200 print
"readline_list_history() not available\n";
219 print
"Bad command\n";
222 if ( function_exists(
'readline_add_history' ) ) {
223 readline_add_history(
$line );
static readconsole( $prompt='> ')
Prompt the console for input.
memcached client class implemented using (p)fsockopen()
$wgObjectCaches
Config variable stub for the ObjectCaches setting, for use by phpdoc and IDEs.
$wgMainCacheType
Config variable stub for the MainCacheType setting, for use by phpdoc and IDEs.
$wgMemCachedServers
Config variable stub for the MemCachedServers setting, for use by phpdoc and IDEs.
mccShowUsage()
Show this command line tool usage.