File: memcachedserver.phpt

package info (click to toggle)
php-memcached 3.2.0%2B2.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,568 kB
  • sloc: ansic: 9,752; xml: 1,350; php: 478; pascal: 123; sh: 12; makefile: 5
file content (119 lines) | stat: -rw-r--r-- 2,905 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
--TEST--
MemcachedServer
--SKIPIF--
<?php
if (!extension_loaded("memcached")) {
	die("skip memcached is not loaded\n");
}
if (!class_exists("MemcachedServer")) {
	die("skip memcached not built with libmemcachedprotocol support\n");
}

if (Memcached::LIBMEMCACHED_VERSION_HEX < 0x1001000) {
       die("skip needs at least libmemcached 1.1.0\n");
}
?>
--FILE--
<?php
include __DIR__ . '/server.inc';
$server = memcached_server_start();

$cache = new Memcached();
$cache->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$cache->setOption(Memcached::OPT_COMPRESSION, false);
$cache->addServer('127.0.0.1', 3434);

$cache->add("add_key", "hello", 500);
$cache->append("append_key", "world");
$cache->prepend("prepend_key", "world");

$cache->increment("incr", 2, 1, 500);
$cache->decrement("decr", 2, 1, 500);

$cache->delete("delete_k");
$cache->flush(1);

var_dump($cache->get('get_this'));

$cache->set ('set_key', 'value 1', 100);
$cache->replace ('replace_key', 'value 2', 200);

var_dump($cache->getVersion());
var_dump($cache->getStats());
var_dump($cache->getStats("empty"));
var_dump($cache->getStats("foobar"));
var_dump($cache->getStats("scalar"));
var_dump($cache->getStats("numeric array"));

$cache->quit();
usleep(50000);

memcached_server_stop($server);
?>
Done
--EXPECTF--
Listening on 127.0.0.1:3434
Incoming connection from 127.0.0.1:%s
Incoming connection from 127.0.0.1:%s
client_id=[%s]: Add key=[add_key], value=[hello], flags=[0], expiration=[500]
client_id=[%s]: Append key=[append_key], value=[world], cas=[0]
client_id=[%s]: Prepend key=[prepend_key], value=[world], cas=[0]
client_id=[%s]: Incrementing key=[incr], delta=[2], initial=[1], expiration=[500]
client_id=[%s]: Decrementing key=[decr], delta=[2], initial=[1], expiration=[500]
client_id=[%s]: Delete key=[delete_k], cas=[0]
client_id=[%s]: Flush when=[1]
client_id=[%s]: Get key=[get_this]
client_id=[%s]: Noop
string(20) "Hello to you client!"
client_id=[%s]: Set key=[set_key], value=[value 1], flags=[0], expiration=[100], cas=[0]
client_id=[%s]: Replace key=[replace_key], value=[value 2], flags=[0], expiration=[200], cas=[0]
client_id=[%s]: Version
array(1) {
  ["127.0.0.1:3434"]=>
  string(5) "1.1.1"
}
client_id=[%s]: Stat key=[]
array(1) {
  ["127.0.0.1:3434"]=>
  array(2) {
    ["key"]=>
    string(0) ""
    ["foo"]=>
    string(3) "bar"
  }
}
client_id=[%s]: Stat key=[empty]
array(0) {
}
client_id=[%s]: Stat key=[foobar]
array(1) {
  ["127.0.0.1:3434"]=>
  array(2) {
    ["key"]=>
    string(6) "foobar"
    ["foo"]=>
    string(3) "bar"
  }
}
client_id=[%s]: Stat key=[scalar]
array(1) {
  ["127.0.0.1:3434"]=>
  array(1) {
    [0]=>
    string(%d) "you want it, you get it"
  }
}
client_id=[%s]: Stat key=[numeric array]
array(1) {
  ["127.0.0.1:3434"]=>
  array(3) {
    [-1]=>
    string(3) "one"
    [0]=>
    string(3) "two"
    [1]=>
    string(5) "three"
  }
}
client_id=[%s]: Client quit
Done