|
| 1 | +--TEST-- |
| 2 | +MemcachedServer |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +if (!extension_loaded("memcached")) { |
| 6 | + die("skip memcached is not loaded\n"); |
| 7 | +} |
| 8 | +if (!class_exists("MemcachedServer")) { |
| 9 | + die("skip memcached not built with libmemcachedprotocol support\n"); |
| 10 | +} |
| 11 | +?> |
| 12 | +--FILE-- |
| 13 | +<?php |
| 14 | +include __DIR__ . '/server.inc'; |
| 15 | +$server = memcached_server_start('server.php', '[::1]', 3434); |
| 16 | + |
| 17 | +$cache = new Memcached(); |
| 18 | +$cache->setOption(Memcached::OPT_BINARY_PROTOCOL, true); |
| 19 | +$cache->setOption(Memcached::OPT_COMPRESSION, false); |
| 20 | +$cache->addServer('[::1]', 3434); |
| 21 | + |
| 22 | +$cache->add("add_key", "hello", 500); |
| 23 | +$cache->append("append_key", "world"); |
| 24 | +$cache->prepend("prepend_key", "world"); |
| 25 | + |
| 26 | +$cache->increment("incr", 2, 1, 500); |
| 27 | +$cache->decrement("decr", 2, 1, 500); |
| 28 | + |
| 29 | +$cache->delete("delete_k"); |
| 30 | +$cache->flush(1); |
| 31 | + |
| 32 | +var_dump($cache->get('get_this')); |
| 33 | + |
| 34 | +$cache->set ('set_key', 'value 1', 100); |
| 35 | +$cache->replace ('replace_key', 'value 2', 200); |
| 36 | + |
| 37 | +var_dump($cache->getVersion()); |
| 38 | +var_dump($cache->getStats()); |
| 39 | +var_dump($cache->getStats("empty")); |
| 40 | +var_dump($cache->getStats("foobar")); |
| 41 | +var_dump($cache->getStats("scalar")); |
| 42 | +var_dump($cache->getStats("numeric array")); |
| 43 | + |
| 44 | +$cache->quit(); |
| 45 | +usleep(50000); |
| 46 | + |
| 47 | +memcached_server_stop($server); |
| 48 | +?> |
| 49 | +Done |
| 50 | +--EXPECTF-- |
| 51 | +Listening on [::1]:3434 |
| 52 | +Incoming connection from [::1]:%s |
| 53 | +Incoming connection from [::1]:%s |
| 54 | +client_id=[%s]: Add key=[add_key], value=[hello], flags=[0], expiration=[500] |
| 55 | +client_id=[%s]: Append key=[append_key], value=[world], cas=[0] |
| 56 | +client_id=[%s]: Prepend key=[prepend_key], value=[world], cas=[0] |
| 57 | +client_id=[%s]: Incrementing key=[incr], delta=[2], initial=[1], expiration=[500] |
| 58 | +client_id=[%s]: Decrementing key=[decr], delta=[2], initial=[1], expiration=[500] |
| 59 | +client_id=[%s]: Delete key=[delete_k], cas=[0] |
| 60 | +client_id=[%s]: Flush when=[1] |
| 61 | +client_id=[%s]: Get key=[get_this] |
| 62 | +client_id=[%s]: Noop |
| 63 | +string(20) "Hello to you client!" |
| 64 | +client_id=[%s]: Set key=[set_key], value=[value 1], flags=[0], expiration=[100], cas=[0] |
| 65 | +client_id=[%s]: Replace key=[replace_key], value=[value 2], flags=[0], expiration=[200], cas=[0] |
| 66 | +client_id=[%s]: Version |
| 67 | +array(1) { |
| 68 | + ["[::1]:3434"]=> |
| 69 | + string(5) "1.1.1" |
| 70 | +} |
| 71 | +client_id=[%s]: Stat key=[] |
| 72 | +array(1) { |
| 73 | + ["[::1]:3434"]=> |
| 74 | + array(2) { |
| 75 | + ["key"]=> |
| 76 | + string(0) "" |
| 77 | + ["foo"]=> |
| 78 | + string(3) "bar" |
| 79 | + } |
| 80 | +} |
| 81 | +client_id=[%s]: Stat key=[empty] |
| 82 | +array(0) { |
| 83 | +} |
| 84 | +client_id=[%s]: Stat key=[foobar] |
| 85 | +array(1) { |
| 86 | + ["[::1]:3434"]=> |
| 87 | + array(2) { |
| 88 | + ["key"]=> |
| 89 | + string(6) "foobar" |
| 90 | + ["foo"]=> |
| 91 | + string(3) "bar" |
| 92 | + } |
| 93 | +} |
| 94 | +client_id=[%s]: Stat key=[scalar] |
| 95 | +array(1) { |
| 96 | + ["[::1]:3434"]=> |
| 97 | + array(1) { |
| 98 | + [0]=> |
| 99 | + string(%d) "you want it, you get it" |
| 100 | + } |
| 101 | +} |
| 102 | +client_id=[%s]: Stat key=[numeric array] |
| 103 | +array(1) { |
| 104 | + ["[::1]:3434"]=> |
| 105 | + array(3) { |
| 106 | + [-1]=> |
| 107 | + string(3) "one" |
| 108 | + [0]=> |
| 109 | + string(3) "two" |
| 110 | + [1]=> |
| 111 | + string(5) "three" |
| 112 | + } |
| 113 | +} |
| 114 | +client_id=[%s]: Client quit |
| 115 | +Done |
0 commit comments