Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

mcc.php

Go to the documentation of this file.
00001 <?php 00002 00003 require_once( "commandLine.inc" ); 00004 00005 $mcc = new memcached( array('persistant' => true) ); 00006 $mcc->set_servers( $wgMemCachedServers ); 00007 $mcc->set_debug( true ); 00008 00009 do { 00010 $bad = false; 00011 $quit = false; 00012 $line = readconsole( "> " ); 00013 $args = explode( " ", $line ); 00014 $command = array_shift( $args ); 00015 switch ( $command ) { 00016 case "get": 00017 print "Getting {$args[0]}[{$args[1]}]\n"; 00018 $res = $mcc->get( $args[0] ); 00019 if ( array_key_exists( 1, $args ) ) { 00020 $res = $res[$args[1]]; 00021 } 00022 if ( $res === false ) { 00023 #print 'Error: ' . $mcc->error_string() . "\n"; 00024 print "MemCached error\n"; 00025 } elseif ( is_string( $res ) ) { 00026 print "$res\n"; 00027 } else { 00028 var_dump( $res ); 00029 } 00030 break; 00031 case "set": 00032 $key = array_shift( $args ); 00033 if ( $args[0] == "#" && is_numeric( $args[1] ) ) { 00034 $value = str_repeat( "*", $args[1] ); 00035 } else { 00036 $value = implode( " ", $args ); 00037 } 00038 if ( !$mcc->set( $key, $value, 0 ) ) { 00039 #print 'Error: ' . $mcc->error_string() . "\n"; 00040 print "MemCached error\n"; 00041 } 00042 break; 00043 case "delete": 00044 $key = implode( " ", $args ); 00045 if ( !$mcc->delete( $key ) ) { 00046 #print 'Error: ' . $mcc->error_string() . "\n"; 00047 print "MemCached error\n"; 00048 } 00049 break; 00050 case "quit": 00051 $quit = true; 00052 break; 00053 default: 00054 $bad = true; 00055 } 00056 if ( $bad ) { 00057 if ( $command ) { 00058 print "Bad command\n"; 00059 } 00060 } else { 00061 if ( function_exists( "readline_add_history" ) ) { 00062 readline_add_history( $line ); 00063 } 00064 } 00065 } while ( !$quit ); 00066 00067 ?> 00068

Generated on Tue Jun 29 23:40:05 2004 for Mediawiki by doxygen 1.3.7