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++ ) {
174 $key = array_shift(
$args );
175 if (
$args[0] ==
"#" && is_numeric(
$args[1] ) ) {
176 $value = str_repeat(
'*',
$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";
static readconsole( $prompt='> ')
Prompt the console for input.