blob: 6ebbfc1b35f7d3abc2b4863e8372dc19e688e348 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?php
require_once( "commandLine.inc" );
$mcc = new memcached( array('persistant' => true) );
$mcc->set_servers( $wgMemCachedServers );
$mcc->set_debug( true );
do {
$bad = false;
$quit = false;
$line = readconsole( "> " );
$args = explode( " ", $line );
$command = array_shift( $args );
switch ( $command ) {
case "get":
print "Getting {$args[0]}[{$args[1]}]\n";
$res = $mcc->get( $args[0] );
if ( array_key_exists( 1, $args ) ) {
$res = $res[$args[1]];
}
if ( $res === false ) {
#print 'Error: ' . $mcc->error_string() . "\n";
print "MemCached error\n";
} elseif ( is_string( $res ) ) {
print "$res\n";
} else {
var_dump( $res );
}
break;
case "set":
$key = array_shift( $args );
if ( $args[0] == "#" && is_numeric( $args[1] ) ) {
$value = str_repeat( "*", $args[1] );
} else {
$value = implode( " ", $args );
}
if ( !$mcc->set( $key, $value, 0 ) ) {
#print 'Error: ' . $mcc->error_string() . "\n";
print "MemCached error\n";
}
break;
case "delete":
$key = implode( " ", $args );
if ( !$mcc->delete( $key ) ) {
#print 'Error: ' . $mcc->error_string() . "\n";
print "MemCached error\n";
}
break;
case "quit":
$quit = true;
break;
default:
$bad = true;
}
if ( $bad ) {
if ( $command ) {
print "Bad command\n";
}
} else {
if ( function_exists( "readline_add_history" ) ) {
readline_add_history( $line );
}
}
} while ( !$quit );
?>
|