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 ) {
167 for ( $i = 0; $i < 3; $i++ ) {
175 $key = array_shift(
$args );
176 if (
$args[0] ==
"#" && is_numeric(
$args[1] ) ) {
177 $value = str_repeat(
'*',
$args[1] );
179 $value = implode(
' ',
$args );
181 if ( !
$mcc->set( $key, $value, 0 ) ) {
182 # print 'Error: ' . $mcc->error_string() . "\n";
183 print "MemCached error\n";
188 $key = implode(
' ',
$args );
189 if ( !
$mcc->delete( $key ) ) {
190 # print 'Error: ' . $mcc->error_string() . "\n";
191 print "MemCached error\n";
196 if ( function_exists(
'readline_list_history' ) ) {
197 foreach ( readline_list_history() as $num =>
$line ) {
198 print "$num: $line\n";
201 print "readline_list_history() not available\n";
220 print "Bad command\n";
static readconsole( $prompt='> ')
Prompt the console for input.