/home/lnzliplg/public_html/alt-php80-pecl-memcached_3.2.0-1.el8.zip
PK
Y�\^(E�y y tests/getdelayed.phptnu �[��� --TEST--
Memcached getDelayed callback
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$data = array(
'foo' => 'foo-data',
'bar' => 'bar-data',
'baz' => 'baz-data',
'lol' => 'lol-data',
'kek' => 'kek-data',
);
foreach ($data as $k => $v) {
$m->set($k, $v, 3600);
}
function myfunc() {
$datas = func_get_args();
if (isset($datas[1])) {
var_dump($datas[1]);
}
}
$m->getDelayed(array_keys($data), true, 'myfunc');
?>
--EXPECTF--
array(4) {
["key"]=>
string(3) "foo"
["value"]=>
string(8) "foo-data"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}
array(4) {
["key"]=>
string(3) "bar"
["value"]=>
string(8) "bar-data"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}
array(4) {
["key"]=>
string(3) "baz"
["value"]=>
string(8) "baz-data"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}
array(4) {
["key"]=>
string(3) "lol"
["value"]=>
string(8) "lol-data"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}
array(4) {
["key"]=>
string(3) "kek"
["value"]=>
string(8) "kek-data"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}PK
Y�\2�o�! ! tests/flush_buffers.phptnu �[��� --TEST--
Test flushing buffers
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance (array (
Memcached::OPT_NO_BLOCK => 1,
Memcached::OPT_BUFFER_WRITES => 1,
));
$key = uniqid ('flush_key_');
var_dump ($m->set($key, 'test_val'));
$m2 = memc_get_instance ();
var_dump ($m2->get ($key));
var_dump ($m->flushBuffers ());
sleep (1);
var_dump ($m2->get ($key));
echo "OK" . PHP_EOL;
?>
--EXPECT--
bool(true)
bool(false)
bool(true)
string(8) "test_val"
OKPK Y�\�iP�_ _ tests/gh_93.phptnu �[��� --TEST--
Test for Github issue #93 (double and long overflow)
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance (array (
Memcached::OPT_COMPRESSION => false
));
function testOverflow($m, $value) {
$m->delete('overflow');
if (true !== $m->set('overflow', $value)) {
echo "Error storing 'overflow' variable\n";
return false;
}
if (true !== $m->prepend('overflow', str_repeat('0', 128))) {
echo "Error prepending key\n";
return false;
}
$v = @$m->get('overflow');
if ($v !== $value) {
// At least it doesn't segfault, so we're happy for now
// echo "Error receiving 'overflow' variable\n";
// return false;
return true;
}
return true;
}
if (!testOverflow($m, 10)) {
return;
}
if (!testOverflow($m, 9.09)) {
return;
}
echo "OK\n";
?>
--EXPECT--
OKPK Y�\:T-W� � tests/gh_500.phptnu �[��� --TEST--
Test for Github issue 500
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = new Memcached();
$newServers = array(
array(MEMC_SERVER_HOST, MEMC_SERVER_PORT),
);
$m->addServers($newServers);
$m->set('floatpoint', 100.2);
$n = $m->get('floatpoint');
var_dump($n);
$m->set('floatpoint_neg', -300.4);
$n = $m->get('floatpoint_neg');
var_dump($n);
?>
--EXPECT--
float(100.2)
float(-300.4)
PK Y�\��w� � tests/types_json_multi.phptnu �[��� --TEST--
Memcached multi store & multi fetch type and value correctness using JSON serializer
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_JSON) print "skip json not enabled";
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
include dirname (__FILE__) . '/types.inc';
memc_run_test ('memc_types_test_multi',
memc_create_combinations ('JSON', Memcached::SERIALIZER_JSON, true)
);
?>
--EXPECT--
TEST DONE
PK Y�\C��Z
tests/user-flags.phptnu �[��� --TEST--
Memcached user flags
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
function check_flags ($flags, $expected_flags)
{
foreach ($expected_flags as $f) {
if (($flags & $f) != $f) {
echo "Flag {$f} is not set" . PHP_EOL;
return;
}
}
echo "Flags OK" . PHP_EOL;
}
function get_flags($m, $key) {
return $m->get($key, null, Memcached::GET_EXTENDED)['flags'];
}
define ('FLAG_1', 1);
define ('FLAG_2', 2);
define ('FLAG_4', 4);
define ('FLAG_32', 32);
define ('FLAG_64', 64);
define ('FLAG_TOO_LARGE', pow(2, 16));
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance (array (Memcached::OPT_BINARY_PROTOCOL => true));
$key = uniqid ('udf_test_');
// Set with flags off
$m->set ($key, '1', 10);
$v = $m->get($key, null, Memcached::GET_EXTENDED);
var_dump($v);
// Set flags on
$m->setOption(Memcached::OPT_USER_FLAGS, FLAG_1);
$m->set ($key, '1', 10);
$m->get($key);
check_flags(get_flags($m, $key), array(FLAG_1));
// Multiple flags
$m->setOption(Memcached::OPT_USER_FLAGS, FLAG_1 | FLAG_2 | FLAG_4);
$m->set ($key, '1', 10);
$m->get($key);
check_flags(get_flags($m, $key), array(FLAG_1, FLAG_2, FLAG_4));
// Even more flags
$m->setOption(Memcached::OPT_USER_FLAGS, FLAG_1 | FLAG_2 | FLAG_4 | FLAG_32 | FLAG_64);
$m->set ($key, '1', 10);
$m->get($key);
check_flags(get_flags($m, $key), array(FLAG_1, FLAG_2, FLAG_4, FLAG_32, FLAG_64));
// User flags with get multi
$values = array(
uniqid ('udf_test_multi_') => "first",
uniqid ('udf_test_multi_') => "second",
uniqid ('udf_test_multi_') => "third",
);
$m->setOption(Memcached::OPT_USER_FLAGS, FLAG_2 | FLAG_4);
$m->setMulti($values);
$m->getMulti(array_keys($values));
$flags = $m->getMulti(array_keys($values), Memcached::GET_EXTENDED);
foreach (array_keys($values) as $key) {
check_flags($flags[$key]['flags'], array(FLAG_2, FLAG_4));
}
// User flags with compression on
$m->setOption(Memcached::OPT_USER_FLAGS, FLAG_1 | FLAG_2 | FLAG_4);
$m->setOption(Memcached::OPT_COMPRESSION, true);
$m->setOption(Memcached::OPT_COMPRESSION_TYPE, Memcached::COMPRESSION_FASTLZ);
$m->set ($key, '1', 10);
$m->get($key);
check_flags(get_flags($m, $key), array(FLAG_1, FLAG_2, FLAG_4));
// Too large flags
$m->setOption(Memcached::OPT_USER_FLAGS, FLAG_TOO_LARGE);
echo "DONE TEST\n";
?>
--EXPECTF--
array(3) {
["value"]=>
string(1) "1"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}
Flags OK
Flags OK
Flags OK
Flags OK
Flags OK
Flags OK
Flags OK
Warning: Memcached::setOption(): MEMC_OPT_USER_FLAGS must be < 65535 in %s on line %d
DONE TESTPK
Y�\�͙c� � tests/types_msgpack.phptnu �[��� --TEST--
Memcached store & fetch type and value correctness using msgpack serializer
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_MSGPACK) print "skip msgpack not enabled";
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
include dirname (__FILE__) . '/types.inc';
memc_run_test ('memc_types_test',
memc_create_combinations ('msgpack', Memcached::SERIALIZER_MSGPACK, version_compare(phpversion("msgpack"), "0.5.5", "<="))
);
?>
--EXPECT--
TEST DONE
PK
Y�\ n�� � tests/bug_16959.phptnu �[��� --TEST--
Memcached: Bug #16959 (getMulti + BINARY_PROTOCOL problem)
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$cache = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true
));
$cache->set('key_0', 'value0');
$cache->set('key_0_additional', 'value0_additional');
// -------------- NORMAL
echo "NORMAL\n";
$keys = array( 'key_0', 'key_0_additional' );
$values = $cache->getMulti($keys);
echo $cache->getResultMessage(), "\n";
echo "Values:\n";
foreach ($values as $k => $v) {
var_dump($k);
var_dump($v);
var_dump($values[$k]);
}
// --------------- REVERSED KEY ORDER
echo "REVERSED KEY ORDER\n";
$keys = array( 'key_0_additional', 'key_0' );
$values = $cache->getMulti($keys);
echo $cache->getResultMessage(), "\n";
echo "Values:\n";
foreach ($values as $k => $v) {
var_dump($k);
var_dump($v);
var_dump($values[$k]);
}
--EXPECT--
NORMAL
SUCCESS
Values:
string(5) "key_0"
string(6) "value0"
string(6) "value0"
string(16) "key_0_additional"
string(17) "value0_additional"
string(17) "value0_additional"
REVERSED KEY ORDER
SUCCESS
Values:
string(16) "key_0_additional"
string(17) "value0_additional"
string(17) "value0_additional"
string(5) "key_0"
string(6) "value0"
string(6) "value0"
PK
Y�\h���h h tests/types_php_multi.phptnu �[��� --TEST--
Memcached multi store & fetch type and value correctness using PHP serializer
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
include dirname (__FILE__) . '/types.inc';
memc_run_test ('memc_types_test_multi',
memc_create_combinations ('PHP', Memcached::SERIALIZER_PHP)
);
?>
--EXPECT--
TEST DONE
PK Y�\()PO� � tests/gh_155.phptnu �[��� --TEST--
Test for bug 155
--SKIPIF--
<?php
$min_version = "1.4.8";
include dirname(__FILE__) . "/skipif.inc";
// The touch command in binary mode will work in libmemcached 1.0.16, but runs out the timeout clock
// See https://github.com/php-memcached-dev/php-memcached/issues/310 for further explanation
// The problem is fixed fully in libmemcached 1.0.18, so we'll focus tests on that version
if (Memcached::LIBMEMCACHED_VERSION_HEX < 0x01000018) die ('skip too old libmemcached');
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = new Memcached ();
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$m->addServer(MEMC_SERVER_HOST, MEMC_SERVER_PORT);
$key = 'bug_155_' . uniqid();
$m->set ($key, 'test', time() + 86400);
$m->get ($key);
echo "GET: " . $m->getResultMessage() . PHP_EOL;
$m->touch ($key, time() + 86400);
echo "TOUCH: " . $m->getResultMessage() . PHP_EOL;
$m->touch ($key, time() + 86400);
echo "TOUCH: " . $m->getResultMessage() . PHP_EOL;
$m->get ($key);
echo "GET: " . $m->getResultMessage() . PHP_EOL;
$m->get ($key);
echo "GET: " . $m->getResultMessage() . PHP_EOL;
echo "DONE" . PHP_EOL;
--EXPECT--
GET: SUCCESS
TOUCH: SUCCESS
TOUCH: SUCCESS
GET: SUCCESS
GET: SUCCESS
DONE
PK Y�\�_�]a a tests/getmulti.phptnu �[��� --TEST--
Memcached::getMulti()
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
class Foo {
function __toString() {
return 'a-foo';
}
}
$data = array();
for ($i = 0; $i < 1000; $i++) {
$data['key' . $i] = 'value' . $i;
}
$data['a-foo'] = 'a-last';
var_dump($m->setMulti($data));
$keys = array_keys($data);
$keys['last'] = new Foo();
$v = $m->getMulti($keys);
var_dump(is_array($v));
var_dump($m->getResultCode() == Memcached::RES_SUCCESS);
if (is_array($v)) {
foreach ($v as $key => $value) {
if (!isset($data[$key]) or $value !== $data[$key]) {
echo "mismatch \$data['$key'] = \n";
var_dump($data[$key]);
var_dump($value);
}
}
} else {
echo "Result not an array\n";
}
var_dump(is_object($keys['last']));
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
PK Y�\�A3� � tests/stats_hang.phptnu �[��� --TEST--
Check stats does not hang on non-blocking binary protocol
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$key = MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT;
// Both options set means we have to reconnect to get stats
$m->setOption(Memcached::OPT_NO_BLOCK, true);
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$stats = $m->getStats();
$conns1 = $stats[$key]['total_connections'];
$stats = $m->getStats();
$conns2 = $stats[$key]['total_connections'];
var_dump($conns1 == $conns2);
var_dump($m->getOption(Memcached::OPT_NO_BLOCK));
var_dump($m->getOption(Memcached::OPT_BINARY_PROTOCOL));
echo "OK" . PHP_EOL;
// If either or both options are false no need to reconnect
$m->setOption(Memcached::OPT_NO_BLOCK, false);
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$stats = $m->getStats();
$conns1 = $stats[$key]['total_connections'];
$stats = $m->getStats();
$conns2 = $stats[$key]['total_connections'];
var_dump($conns1 == $conns2);
var_dump($m->getOption(Memcached::OPT_NO_BLOCK));
var_dump($m->getOption(Memcached::OPT_BINARY_PROTOCOL));
echo "OK" . PHP_EOL;
// If either or both options are false no need to reconnect
$m->setOption(Memcached::OPT_NO_BLOCK, true);
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, false);
$stats = $m->getStats();
$conns1 = $stats[$key]['total_connections'];
$stats = $m->getStats();
$conns2 = $stats[$key]['total_connections'];
var_dump($conns1 == $conns2);
var_dump($m->getOption(Memcached::OPT_NO_BLOCK));
var_dump($m->getOption(Memcached::OPT_BINARY_PROTOCOL));
echo "OK" . PHP_EOL;
// If either or both options are false no need to reconnect
$m->setOption(Memcached::OPT_NO_BLOCK, false);
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, false);
$stats = $m->getStats();
$conns1 = $stats[$key]['total_connections'];
$stats = $m->getStats();
$conns2 = $stats[$key]['total_connections'];
var_dump($conns1 == $conns2);
var_dump($m->getOption(Memcached::OPT_NO_BLOCK));
var_dump($m->getOption(Memcached::OPT_BINARY_PROTOCOL));
echo "OK" . PHP_EOL;
?>
--EXPECT--
bool(false)
int(1)
int(1)
OK
bool(true)
int(0)
int(1)
OK
bool(true)
int(1)
int(0)
OK
bool(true)
int(0)
int(0)
OK
PK Y�\�ճ�� � tests/no-not-found.phptnu �[��� --TEST--
Test that correct return value is returned
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$memcached = new Memcached();
$memcached->addServer('localhost', 5555); // Server should not exist
$result = $memcached->get('foo_not_exists');
var_dump ($result === Memcached::GET_ERROR_RETURN_VALUE);
$result = $memcached->get('foo_not_exists');
var_dump ($result === Memcached::GET_ERROR_RETURN_VALUE);
echo "OK\n";
?>
--EXPECT--
bool(true)
bool(true)
OK
PK Y�\�*xpB B tests/localserver.phptnu �[��� --TEST--
Memcached local server test
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$key = 'foobarbazDEADC0DE';
$m->set($key, array(
'foo' => 'bar'
), 360);
var_dump($m->get($key));
?>
--EXPECT--
array(1) {
["foo"]=>
string(3) "bar"
}
PK Y�\g|�D tests/vbucket_error_7.phptnu �[��� --TEST--
Memcached virtual buckets
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!defined("Memcached::DISTRIBUTION_VIRTUAL_BUCKET")) die ("skip DISTRIBUTION_VIRTUAL_BUCKET not defined");
if (PHP_VERSION_ID >= 80000) die("skip PHP 7 only");
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance (array (
Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_VIRTUAL_BUCKET
));
var_dump ($m->setBucket (array (), null, 2));
var_dump ($m->setBucket (array (), array (), -1));
var_dump ($m->setBucket (null, array (), -1));
var_dump ($m->setBucket (array (-1), array (-1), 1));
echo "OK\n";
?>
--EXPECTF--
Warning: Memcached::setBucket(): server map cannot be empty in %s on line %d
bool(false)
Warning: Memcached::setBucket(): server map cannot be empty in %s on line %d
bool(false)
Warning: Memcached::setBucket() expects parameter 1 to be array, null given in %s on line %d
NULL
Warning: Memcached::setBucket(): the map must contain positive integers in %s on line %d
bool(false)
OK
PK Y�\>w�b� � tests/session_lock.phptnu �[��� --TEST--
Session lock
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
if (PHP_VERSION_ID >= 70100) print "skip";
?>
--INI--
memcached.sess_locking = true
memcached.sess_lock_wait_min = 500
memcached.sess_lock_wait_max = 1000
memcached.sess_lock_retries = 3
memcached.sess_prefix = "memc.test."
# Turn off binary protocol while the test matrix has older versions of
# libmemcached for which the extension warns of a broken touch command.
memcached.sess_binary_protocol = Off
session.save_handler = memcached
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = new Memcached();
$m->addServer(MEMC_SERVER_HOST, MEMC_SERVER_PORT);
ob_start();
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
session_start();
$session_id = session_id();
$_SESSION["test"] = "hello";
session_write_close();
session_start();
var_dump ($m->get ('memc.test.' . session_id()));
var_dump ($m->get ('memc.test.lock.' . session_id()));
session_write_close();
var_dump ($m->get ('memc.test.lock.' . session_id()));
// Test lock min / max
$m->set ('memc.test.lock.' . $session_id, '1');
$time_start = microtime(true);
session_start();
$time = microtime(true) - $time_start;
if (round ($time, 1) != 2.5) {
echo "Waited longer than expected: $time" . PHP_EOL;
}
echo "OK";
--EXPECTF--
string(17) "test|s:5:"hello";"
string(1) "1"
bool(false)
Warning: session_start(): Unable to clear session lock record in %s on line %d
OK
PK Y�\�Z�$� � tests/compression_types.phptnu �[��� --TEST--
Memcached compression test
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$data = file_get_contents(dirname(__FILE__) . '/testdata.res');
function get_compression($name) {
switch (strtolower($name)) {
case 'zlib':
return Memcached::COMPRESSION_ZLIB;
case 'fastlz':
return Memcached::COMPRESSION_FASTLZ;
default:
echo "Strange compression type: $name\n";
return 0;
}
}
function fetch_with_compression($m, $key, $value, $set_compression = '', $get_compression = '') {
echo "set=[$set_compression] get=[$get_compression]\n";
if (!$set_compression) {
$m->setOption(Memcached::OPT_COMPRESSION, false);
} else {
$m->setOption(Memcached::OPT_COMPRESSION, true);
$m->setOption(Memcached::OPT_COMPRESSION_TYPE, get_compression($set_compression));
}
$m->set($key, $value, 1800);
if (!$get_compression) {
$m->setOption(Memcached::OPT_COMPRESSION, true);
} else {
$m->setOption(Memcached::OPT_COMPRESSION, true);
$m->setOption(Memcached::OPT_COMPRESSION_TYPE, get_compression($get_compression));
}
$value_back = $m->get($key);
var_dump($value === $value_back);
}
fetch_with_compression($m, 'hello1', $data, 'zlib', 'zlib');
fetch_with_compression($m, 'hello2', $data, 'zlib', 'fastlz');
fetch_with_compression($m, 'hello3', $data, 'fastlz', 'fastlz');
fetch_with_compression($m, 'hello4', $data, 'fastlz', 'zlib');
fetch_with_compression($m, 'hello5', $data, '', 'zlib');
fetch_with_compression($m, 'hello6', $data, '', 'fastlz');
fetch_with_compression($m, 'hello7', $data, 'zlib', '');
fetch_with_compression($m, 'hello8', $data, 'fastlz', '');
fetch_with_compression($m, 'hello9', $data, '', '');
?>
--EXPECT--
set=[zlib] get=[zlib]
bool(true)
set=[zlib] get=[fastlz]
bool(true)
set=[fastlz] get=[fastlz]
bool(true)
set=[fastlz] get=[zlib]
bool(true)
set=[] get=[zlib]
bool(true)
set=[] get=[fastlz]
bool(true)
set=[zlib] get=[]
bool(true)
set=[fastlz] get=[]
bool(true)
set=[] get=[]
bool(true)
PK Y�\3�� � tests/construct_persistent.phptnu �[��� --TEST--
persistent memcached connection
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$m1 = new Memcached('id1');
$m1->setOption(Memcached::OPT_PREFIX_KEY, 'php');
var_dump($m1->getOption(Memcached::OPT_PREFIX_KEY));
$m2 = new Memcached('id1');
var_dump($m1->getOption(Memcached::OPT_PREFIX_KEY));
$m3 = new Memcached();
var_dump($m3->getOption(Memcached::OPT_PREFIX_KEY));
?>
--EXPECT--
string(3) "php"
string(3) "php"
string(0) ""
PK Y�\��kp� � tests/gh_21.phptnu �[��� --TEST--
Test for Github issue 21
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = new Memcached();
$newServers = array(
array(MEMC_SERVER_HOST, MEMC_SERVER_PORT),
);
$m->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$m->addServers($newServers);
$d = $m->get('foo');
$m->set('counter', 5);
$n = $m->decrement('counter');
var_dump($n);
$n = $m->decrement('counter', 10);
var_dump($n);
var_dump($m->get('counter'));
$m->set('counter', 'abc');
$n = $m->increment('counter');
var_dump($n);
?>
--EXPECT--
int(4)
int(0)
int(0)
bool(false)PK Y�\��� � tests/session_regenerate.phptnu �[��� --TEST--
Session regenerate
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
?>
--INI--
session.save_handler = memcached
--FILE--
<?php
ob_start();
include dirname (__FILE__) . '/config.inc';
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
var_dump(session_start());
var_dump(session_regenerate_id());
var_dump(session_regenerate_id(true));
echo "OK";
--EXPECT--
bool(true)
bool(true)
bool(true)
OK
PK Y�\�mO tests/set_encoding_key2.phptnu �[��� --TEST--
Test libmemcached encryption
--SKIPIF--
<?php
include dirname (__FILE__) . '/config.inc';
if (!extension_loaded("memcached")) die ("skip");
if (!Memcached::HAVE_ENCODING) die ("skip no set_encoding_key support enabled");
if (Memcached::LIBMEMCACHED_VERSION_HEX >= 0x01000018) die ("skip test for libmemcached lower than 1.0.18");
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$key = uniqid ('encoding_test_');
var_dump ($m->setEncodingKey("Hello"));
var_dump ($m->set ($key, 'set using encoding'));
var_dump ($m->get ($key));
echo "OK" . PHP_EOL;
# libmemcached < 1.0.18 goes into a bad state when the encoding key is changed,
# so php-memcached warns and returns false when trying to change the key.
var_dump ($m->setEncodingKey("World"));
echo "OK" . PHP_EOL;
?>
--EXPECTF--
bool(true)
bool(true)
string(18) "set using encoding"
OK
Warning: Memcached::setEncodingKey(): libmemcached versions less than 1.0.18 cannot change encoding key in %s on line %d
bool(false)
OK
PK Y�\p#&S� � tests/multi_order.phptnu �[��� --TEST--
Memcached GET_PRESERVE_ORDER flag in getMulti
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$m->addServer (MEMC_SERVER_HOST, MEMC_SERVER_PORT);
$data = array(
'foo' => 'foo-data',
'bar' => 'bar-data',
'baz' => 'baz-data',
'lol' => 'lol-data',
'kek' => 'kek-data',
);
//$m->setMulti($data, 3600);
foreach ($data as $k => $v) {
$m->set($k, $v, 3600);
}
$keys = array_keys($data);
$keys[] = 'zoo';
$got = $m->getMulti($keys, Memcached::GET_PRESERVE_ORDER);
foreach ($got as $k => $v) {
echo "$k $v\n";
}
?>
--EXPECT--
foo foo-data
bar bar-data
baz baz-data
lol lol-data
kek kek-data
zoo
PK Y�\�,�S� � tests/bug_16084.phptnu �[��� --TEST--
Memcached: Bug #16084 (Crash when addServers is called with an associative array)
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$servers = array ( 0 => array ( 'KEYHERE' => 'localhost', 11211, 3 ), );
$m = new memcached();
var_dump($m->addServers($servers));
$list = $m->getServerList();
var_dump ($list[0]["host"], $list[0]["port"]);
echo "OK";
?>
--EXPECT--
bool(true)
string(9) "localhost"
int(11211)
OK
PK Y�\��h� � tests/getserverbykey.phptnu �[��� --TEST--
Memcached::getServerByKey()
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
error_reporting(0);
$m = new Memcached();
var_dump($m->getServerByKey("a"));
$m->addServer('localhost', 11211, 1);
$m->addServer('localhost', 11212, 1);
$m->addServer('localhost', 11213, 1);
$m->addServer('localhost', 11214, 1);
$m->addServer('localhost', 11215, 1);
var_dump($m->getServerByKey(""));
echo $m->getResultMessage(), "\n";
var_dump($m->getServerByKey("a"));
var_dump($m->getServerByKey("b"));
var_dump($m->getServerByKey("c"));
var_dump($m->getServerByKey("d"));
--EXPECTF--
bool(false)
bool(false)
A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE
array(%d) {
["host"]=>
string(%d) "%s"
["port"]=>
int(%d)
["weight"]=>
int(0)
}
array(%d) {
["host"]=>
string(%d) "%s"
["port"]=>
int(%d)
["weight"]=>
int(0)
}
array(%d) {
["host"]=>
string(%d) "%s"
["port"]=>
int(%d)
["weight"]=>
int(0)
}
array(%d) {
["host"]=>
string(%d) "%s"
["port"]=>
int(%d)
["weight"]=>
int(0)
}
PK Y�\
�~ tests/session_lazy_warning.phptnu �[��� --TEST--
Session lazy binary warning old libmemcached
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
if (Memcached::LIBMEMCACHED_VERSION_HEX >= 0x01000018) die ('skip too recent libmemcached');
?>
--INI--
session.save_handler = memcached
memcached.sess_binary_protocol = On
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
ob_start();
session_start(['lazy_write'=>TRUE]);
$_SESSION['foo'] = 1;
session_write_close();
$_SESSION = NULL;
var_dump($_SESSION);
session_start();
var_dump($_SESSION);
session_write_close();
session_start();
session_destroy();
session_start();
var_dump($_SESSION);
session_write_close();
--EXPECTF--
NULL
array(1) {
["foo"]=>
int(1)
}
Warning: session_write_close(): using touch command with binary protocol is not recommended with libmemcached versions below 1.0.18, please use ascii protocol or upgrade libmemcached in %s on line %d
array(0) {
}
PK Y�\ѵ�jy y tests/undefined_set.phptnu �[��� --TEST--
Set with undefined key and value
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$key = 'foobarbazDEADC0DE';
$value = array('foo' => 'bar');
// silent to hide:
// Warning: Undefined variable
// Deprecated: Memcached::set(): Passing null to parameter (PHP 8.1)
$rv = @$m->set($no_key, $value, 360);
var_dump($rv);
$rv = @$m->set($key, $no_value, 360);
var_dump($rv);
$rv = @$m->set($no_key, $no_value, 360);
var_dump($rv);
$rv = @$m->set($key, $value, $no_time);
var_dump($rv);
?>
--EXPECTF--
bool(false)
bool(true)
bool(false)
bool(true)
PK Y�\|gG� � ! tests/session_badconf_prefix.phptnu �[��� --TEST--
Session bad configurations, prefix
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
?>
--INI--
session.save_handler = memcached
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
ini_set('memcached.sess_prefix', ' sdj jkhasd ');
ini_set('memcached.sess_prefix', str_repeat('a', 512));
echo "OK";
--EXPECTF--
Warning: ini_set(): memcached.sess_prefix cannot contain whitespace or control characters in %s on line %d
Warning: ini_set(): memcached.sess_prefix too long (max: %d) in %s on line %d
OKPK Y�\e��&� � tests/setmulti.phptnu �[��� --TEST--
Memcached::setMulti()
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$data['foo'] = 'bar';
$data[PHP_INT_MAX] = 'int-max';
$data[-PHP_INT_MAX] = 'int-min';
$data[-PHP_INT_MAX - 1] = 'int-min';
$data[0] = 'zero';
$data[123] = 'onetwothree';
$data[-123] = 'negonetwothree';
$keys = array_map('strval', array_keys($data));
echo "Data: ";
var_dump($data);
$m->deleteMulti($keys);
echo "set keys: ";
var_dump($m->setMulti($data, 10));
echo "get: ";
$r = $m->getMulti($keys);
var_dump($r);
echo "Equal: ";
var_dump($r === $data);
--EXPECTF--
Data: array(%d) {
["foo"]=>
string(3) "bar"
[%i]=>
string(7) "int-max"
[%i]=>
string(7) "int-min"
[%i]=>
string(7) "int-min"
[0]=>
string(4) "zero"
[123]=>
string(11) "onetwothree"
[-123]=>
string(14) "negonetwothree"
}
set keys: bool(true)
get: array(%d) {
["foo"]=>
string(3) "bar"
[%i]=>
string(7) "int-max"
[%i]=>
string(7) "int-min"
[%i]=>
string(7) "int-min"
[0]=>
string(4) "zero"
[123]=>
string(11) "onetwothree"
[-123]=>
string(14) "negonetwothree"
}
Equal: bool(true)
PK Y�\��b
tests/testdata.resnu �[��� Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut malesuada purus vel diam congue condimentum. Vivamus diam erat, commodo eget lacinia venenatis, tempor at nulla. Praesent dapibus aliquam lectus. Aliquam erat volutpat. Praesent congue elementum ipsum, eu bibendum nisi ullamcorper nec. Aenean mattis metus quis libero hendrerit blandit accumsan nisi lacinia. Aenean varius sollicitudin nisl, tempor condimentum turpis congue id. Nunc vulputate purus non nunc dignissim tincidunt. Curabitur adipiscing est in ligula interdum a ultrices nibh ultricies. Aliquam a dapibus lectus.
Ut eleifend, dui nec aliquam lobortis, quam est luctus lectus, nec hendrerit augue quam ac odio. Nam condimentum, ligula et rhoncus vulputate, lorem urna adipiscing mauris, non mollis velit arcu non urna. Donec sodales ultrices risus, sed hendrerit libero fringilla vitae. Maecenas magna nisl, vehicula scelerisque hendrerit id, fermentum at lorem. Curabitur eu nisl tincidunt arcu venenatis ultricies. Vivamus velit lorem, hendrerit non imperdiet sit amet, eleifend nec mauris. Donec eget condimentum purus. Cras sed lorem sagittis augue faucibus tincidunt. Pellentesque vitae lorem ac orci dignissim tempor. Maecenas diam elit, pulvinar sed gravida rutrum, ultrices vel mauris. In adipiscing placerat eros imperdiet euismod. Nunc quis ante non lectus dictum porta. Nullam orci felis, tristique ut posuere at, tempor sed eros. Pellentesque accumsan posuere magna eu condimentum. Phasellus adipiscing cursus fringilla. Donec diam ipsum, pharetra quis tempus sit amet, mollis in dolor. Pellentesque volutpat vestibulum nulla quis ultricies. Pellentesque scelerisque erat eu nulla ullamcorper tincidunt.
Nullam commodo lobortis lacus, ac scelerisque diam dignissim eget. Cras eu metus sed tellus accumsan rutrum id ac nunc. Duis rutrum ipsum quis sapien dictum tincidunt. Duis gravida augue et sapien laoreet at pretium eros vulputate. Duis pulvinar lectus quis libero ultricies consequat a id felis. Morbi imperdiet venenatis ipsum eget ultricies. Vivamus fermentum urna sed massa tristique euismod. Pellentesque sed justo ut mi tincidunt luctus semper et elit. In hac habitasse platea dictumst. Praesent suscipit, elit quis fermentum luctus, magna dolor volutpat tellus, nec blandit nulla metus a lacus. Duis gravida, ipsum eu posuere congue, massa augue semper sapien, vel bibendum mi odio nec lectus. Vivamus lacinia urna vitae justo tincidunt dictum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc sed libero metus, in imperdiet nibh.
Integer sapien mauris, pretium sed sodales at, blandit in lacus. Etiam a nisl semper enim pellentesque posuere vitae quis lectus. Etiam ut libero at tortor molestie feugiat non ut ligula. Suspendisse fermentum ipsum vel mauris aliquet convallis. Fusce velit turpis, sollicitudin sit amet luctus id, porta nec ipsum. Fusce consequat, risus vel congue sollicitudin, orci sem auctor nisl, eu consectetur neque tortor id neque. Nunc in odio velit. Duis vitae lacus elit, eu fringilla nulla. Phasellus non mi tellus, volutpat commodo lorem. Pellentesque vel ligula enim. Morbi suscipit, orci sed gravida convallis, nunc leo eleifend lacus, quis elementum dui mi nec risus. Mauris faucibus arcu scelerisque tellus semper dictum. Suspendisse vel posuere turpis. Curabitur ipsum ligula, auctor ut dignissim vel, scelerisque vel mauris. Vivamus est dolor, bibendum ac vestibulum a, congue id felis. Mauris rutrum pharetra tempus. Sed ornare congue purus, id adipiscing mi tincidunt at. Maecenas blandit, lorem in malesuada adipiscing, dolor arcu suscipit magna, ut mollis leo nibh non orci. Sed non massa ipsum, et lobortis tortor. Aliquam et egestas velit.
Mauris ac sem eget elit imperdiet faucibus at non turpis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent vel dui vitae enim imperdiet sodales. Maecenas a tristique mauris. Praesent consectetur risus sit amet lacus dictum ut egestas nibh lacinia. Mauris quam augue, fringilla ac pretium a, consectetur sed risus. Sed ullamcorper eleifend dolor, id tempor arcu sodales at. Vestibulum eget sagittis libero. Cras ornare dui ac ante pretium fringilla. Morbi eu tincidunt felis. Vivamus ultrices diam in eros elementum luctus. Aenean eu neque nibh. Mauris neque est, euismod ut rutrum nec, vehicula at magna. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce sit amet neque ac justo pretium laoreet. Duis non sapien ut eros tristique porttitor vel et lacus. Donec molestie nunc malesuada ante porta ac pretium magna dictum. Nam dolor orci, lacinia egestas ornare eget, viverra et mi. Vivamus convallis lobortis dui, ac sagittis urna mattis sit amet. Duis interdum, est sed dignissim blandit, metus elit scelerisque mauris, sit amet egestas velit arcu quis nunc.
PK Y�\��. . tests/incrdecr_invalid_key.phptnu �[��� --TEST--
Memcached::increment() Memcached::decrement() with invalid key
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
var_dump($m->increment('', 1));
var_dump($m->decrement('', 1));
?>
--EXPECT--
bool(false)
bool(false)
PK Y�\��� tests/check_if_persistent.phptnu �[��� --TEST--
Check if persistent object is persistent
--SKIPIF--
<?php include dirname(__FILE__) . "/skipif.inc";
?>
--FILE--
<?php
$m1 = new Memcached('id1');
$m1->setOption(Memcached::OPT_PREFIX_KEY, "foo_");
var_dump($m1->isPersistent());
$m1 = new Memcached('id1');
var_dump($m1->isPersistent());
$m2 = new Memcached('id1');
var_dump($m2->isPersistent());
// this change affects $m1
$m2->setOption(Memcached::OPT_PREFIX_KEY, "bar_");
$m3 = new Memcached('id2');
var_dump($m3->isPersistent());
$m3 = new Memcached();
var_dump($m3->isPersistent());
// objects have the same resource, but they are not the same object.
var_dump($m1 === $m2);
var_dump($m1->getOption(Memcached::OPT_PREFIX_KEY));
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
string(4) "bar_"
PK Y�\J�E�
tests/bad_construct.phptnu �[��� --TEST--
Memcached construct with bad arguments
--SKIPIF--
<?php
include "skipif.inc";
if (PHP_VERSION_ID >= 80000) die("skip PHP 7 only");
?>
--FILE--
<?php
$m = new Memcached((object)array());
echo error_get_last()["message"], "\n";
var_dump($m);
class extended extends Memcached {
public function __construct () {
}
}
error_reporting(E_ALL);
$extended = new extended ();
var_dump ($extended->setOption (Memcached::OPT_BINARY_PROTOCOL, true));
echo "OK" . PHP_EOL;
--EXPECTF--
Warning: Memcached::__construct() expects parameter 1 to be string, object given in %s on line 3
Memcached::__construct() expects parameter 1 to be string, object given
object(Memcached)#1 (0) {
}
Warning: Memcached::setOption(): Memcached constructor was not called in %s on line 14
NULL
OK
PK Y�\���Ј � tests/deletemultitypes.phptnu �[��� --TEST--
Delete multi key types
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
function dump_types($v, $k) {
echo gettype($v) . "\n";
}
$keys = array(100, 'str');
array_walk($keys, 'dump_types');
$deleted = $m->deleteMulti($keys);
array_walk($keys, 'dump_types');
?>
--EXPECT--
integer
string
integer
stringPK Y�\`��
tests/keys_binary.phptnu �[��� --TEST--
Test valid and invalid keys - binary
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$binary = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true,
));
echo 'BINARY: SPACES' . PHP_EOL;
var_dump ($binary->set ('binary key with spaces', 'this is a test'));
var_dump ($binary->getResultCode () == Memcached::RES_SUCCESS);
echo 'BINARY: NEWLINE' . PHP_EOL;
var_dump ($binary->set ('binarykeywithnewline' . PHP_EOL, 'this is a test'));
var_dump ($binary->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
echo 'BINARY: EMPTY' . PHP_EOL;
var_dump ($binary->set (''/*empty key*/, 'this is a test'));
var_dump ($binary->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
echo 'BINARY: TOO LONG' . PHP_EOL;
var_dump ($binary->set (str_repeat ('1234567890', 512), 'this is a test'));
var_dump ($binary->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
echo 'BINARY: GET' . PHP_EOL;
// Only newline fails in binary mode (char 10)
for ($i=0;$i<32;$i++) {
$binary->delete ('binarykeywithnonprintablechar-' . chr($i) . '-here');
var_dump ($binary->get ('binarykeywithnonprintablechar-' . chr($i) . '-here'));
var_dump ($binary->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
}
echo 'BINARY: SET' . PHP_EOL;
// Only newline fails in binary mode (char 10)
for ($i=0;$i<32;$i++) {
var_dump ($binary->set ('binarykeywithnonprintablechar-' . chr($i) . '-here', 'this is a test'));
var_dump ($binary->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
$binary->delete ('binarykeywithnonprintablechar-' . chr($i) . '-here');
}
echo 'OK' . PHP_EOL;
--EXPECT--
BINARY: SPACES
bool(true)
bool(true)
BINARY: NEWLINE
bool(false)
bool(true)
BINARY: EMPTY
bool(false)
bool(true)
BINARY: TOO LONG
bool(false)
bool(true)
BINARY: GET
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
BINARY: SET
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(false)
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
OK
PK Y�\V}u�� � tests/keys_ascii.phptnu �[��� --TEST--
Test valid and invalid keys - ascii
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$ascii = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => false,
Memcached::OPT_VERIFY_KEY => false
));
// libmemcached can verify keys, but these are tests are for our own
// function s_memc_valid_key_ascii, so explicitly disable the checks
// that libmemcached can perform.
echo 'ASCII: SPACES' . PHP_EOL;
var_dump ($ascii->set ('ascii key with spaces', 'this is a test'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
echo 'ASCII: NEWLINE' . PHP_EOL;
var_dump ($ascii->set ('asciikeywithnewline' . PHP_EOL, 'this is a test'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
echo 'ASCII: EMPTY' . PHP_EOL;
var_dump ($ascii->set (''/*empty key*/, 'this is a test'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
echo 'ASCII: TOO LONG' . PHP_EOL;
var_dump ($ascii->set (str_repeat ('1234567890', 512), 'this is a test'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
echo 'ASCII: GET' . PHP_EOL;
for ($i=0;$i<32;$i++) {
var_dump ($ascii->get ('asciikeywithnonprintablechar-' . chr($i) . '-here'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
}
echo 'ASCII: SET' . PHP_EOL;
for ($i=0;$i<32;$i++) {
var_dump ($ascii->set ('asciikeywithnonprintablechar-' . chr($i) . '-here', 'this is a test'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
}
echo 'OK' . PHP_EOL;
--EXPECT--
ASCII: SPACES
bool(false)
bool(true)
ASCII: NEWLINE
bool(false)
bool(true)
ASCII: EMPTY
bool(false)
bool(true)
ASCII: TOO LONG
bool(false)
bool(true)
ASCII: GET
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
ASCII: SET
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
OK
PK Y�\AW�` ` tests/deletemulti.phptnu �[��� --TEST--
Delete multi
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
function has_all_keys($keys, $array, $check_true = false)
{
foreach ($keys as $key) {
if (!isset($array[$key]))
return false;
if ($check_true && $array[$key] !== true)
return false;
}
return true;
}
$data = array(
'foo' => 'foo-data',
'bar' => 'bar-data',
'baz' => 'baz-data',
'lol' => 'lol-data',
'kek' => 'kek-data',
);
$keys = array_keys($data);
$null = null;
$m->setMulti($data, 3600);
/* Check that all keys were stored */
var_dump(has_all_keys($keys, $m->getMulti($keys)));
/* Check that all keys get deleted */
$deleted = $m->deleteMulti($keys);
var_dump(has_all_keys($keys, $deleted, true));
/* Try to get the deleted keys, should give empty array */
var_dump($m->getMulti($keys));
/* ---- same tests for byKey variants ---- */
$m->setMultiByKey("hi", $data, 3600);
var_dump(has_all_keys($keys, $m->getMultiByKey('hi', $keys)));
/* Check that all keys get deleted */
$deleted = $m->deleteMultiByKey('hi', $keys);
var_dump(has_all_keys($keys, $deleted, true));
/* Try to get the deleted keys, should give empty array */
var_dump($m->getMultiByKey('hi', $keys));
/* Test deleting non-existent keys */
$keys = array();
$keys[] = "nothere";
$keys[] = "nothere2";
$retval = $m->deleteMulti($keys);
foreach ($retval as $key => $value) {
if ($value === Memcached::RES_NOTFOUND) {
echo "$key NOT FOUND\n";
}
}
?>
--EXPECT--
bool(true)
bool(true)
array(0) {
}
bool(true)
bool(true)
array(0) {
}
nothere NOT FOUND
nothere2 NOT FOUNDPK Y�\�ų tests/types_msgpack_multi.phptnu �[��� --TEST--
Memcached multi store & fetch type and value correctness using msgpack serializer
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_MSGPACK) print "skip msgpack not enabled";
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
include dirname (__FILE__) . '/types.inc';
memc_run_test ('memc_types_test_multi',
memc_create_combinations ('msgpack', Memcached::SERIALIZER_MSGPACK, version_compare(phpversion("msgpack"), "0.5.5", "<="))
);
?>
--EXPECT--
TEST DONE
PK Y�\d"� � tests/server.phpnu �[��� <?php
$server = new MemcachedServer();
$server->on (Memcached::ON_CONNECT,
function ($remote_addr) {
echo "Incoming connection from {$remote_addr}" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_ADD,
function ($client_id, $key, $value, $flags, $expiration, &$cas) {
echo "client_id=[$client_id]: Add key=[$key], value=[$value], flags=[$flags], expiration=[$expiration]" . PHP_EOL;
$cas = 15;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_APPEND,
function ($client_id, $key, $value, $cas, &$result_cas) {
echo "client_id=[$client_id]: Append key=[$key], value=[$value], cas=[$cas]" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_PREPEND,
function ($client_id, $key, $value, $cas, &$result_cas) {
echo "client_id=[$client_id]: Prepend key=[$key], value=[$value], cas=[$cas]" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_INCREMENT,
function ($client_id, $key, $delta, $initial, $expiration, &$result, &$result_cas) {
echo "client_id=[$client_id]: Incrementing key=[$key], delta=[$delta], initial=[$initial], expiration=[$expiration]" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_DECREMENT,
function ($client_id, $key, $delta, $initial, $expiration, &$result, &$result_cas) {
echo "client_id=[$client_id]: Decrementing key=[$key], delta=[$delta], initial=[$initial], expiration=[$expiration]" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_DELETE,
function ($client_id, $key, $cas) {
echo "client_id=[$client_id]: Delete key=[$key], cas=[$cas]" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_FLUSH,
function ($client_id, $when) {
echo "client_id=[$client_id]: Flush when=[$when]" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_GET,
function ($client_id, $key, &$value, &$flags, &$cas) {
echo "client_id=[$client_id]: Get key=[$key]" . PHP_EOL;
$value = "Hello to you client!";
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_NOOP,
function ($client_id) {
echo "client_id=[$client_id]: Noop" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_REPLACE,
function ($client_id, $key, $value, $flags, $expiration, $cas, &$result_cas) {
echo "client_id=[$client_id]: Replace key=[$key], value=[$value], flags=[$flags], expiration=[$expiration], cas=[$cas]" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_SET,
function ($client_id, $key, $value, $flags, $expiration, $cas, &$result_cas) {
echo "client_id=[$client_id]: Set key=[$key], value=[$value], flags=[$flags], expiration=[$expiration], cas=[$cas]" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_STAT,
function ($client_id, $key, array &$values) {
echo "client_id=[$client_id]: Stat key=[$key]" . PHP_EOL;
if ($key === "scalar") {
$values = "you want it, you get it";
} elseif ($key === "numeric array") {
$values = [-1 => "one", "two", "three"];
} elseif ($key === "empty") {
$values = [];
} else {
$values["key"] = $key;
$values["foo"] = "bar";
}
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_VERSION,
function ($client_id, &$value) {
echo "client_id=[$client_id]: Version" . PHP_EOL;
$value = "1.1.1";
return Memcached::RESPONSE_SUCCESS;
});
$server->on (Memcached::ON_QUIT,
function ($client_id) {
echo "client_id=[$client_id]: Client quit" . PHP_EOL;
return Memcached::RESPONSE_SUCCESS;
});
$addr = ($_SERVER['argv'][1] ?? "127.0.0.1:3434");
echo "Listening on $addr" . PHP_EOL;
$server->run($addr);
PK Y�\�9�D D tests/clone.phptnu �[��� --TEST--
Test cloning
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$s = new stdClass();
$m = new Memcached();
$s = clone $s;
$m = clone $m;
echo "GOT HERE";
--EXPECTF--
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Memcached in %s:6
Stack trace:
#0 {main}
thrown in %s on line 6
PK Y�\��f� � tests/types_json.phptnu �[��� --TEST--
Memcached store & fetch type and value correctness using JSON serializer
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_JSON) print "skip json not enabled";
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
include dirname (__FILE__) . '/types.inc';
memc_run_test ('memc_types_test',
memc_create_combinations ('JSON', Memcached::SERIALIZER_JSON, true)
);
?>
--EXPECT--
TEST DONE
PK Y�\~�5i� � tests/session_basic.phptnu �[��� --TEST--
Session basic open, write, destroy
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
?>
--INI--
session.save_handler = memcached
memcached.sess_binary_protocol = Off
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
ob_start();
session_start();
$_SESSION['foo'] = 1;
session_write_close();
$_SESSION = NULL;
var_dump($_SESSION);
session_start();
var_dump($_SESSION);
session_write_close();
session_start();
session_destroy();
session_start();
var_dump($_SESSION);
session_write_close();
--EXPECT--
NULL
array(1) {
["foo"]=>
int(1)
}
array(0) {
}
PK Y�\�3S=� � tests/skipif.incnu �[��� <?php
if (!extension_loaded("memcached")) {
die("skip memcached is not loaded\n");
}
include dirname(__FILE__) . "/config.inc";
if (($m = memc_get_instance()) === NULL) {
die ("skip can not connect to server\n");
}
if (isset($min_version)) {
if (version_compare(memc_get_version($m), $min_version, "<")) {
die("skip version of server pool is too old, $min_version is required\n");
}
}
PK Y�\ !r� � tests/getserverlist.phptnu �[��� --TEST--
getServerList
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$servers = array ( 0 => array ( 'KEYHERE' => 'localhost', 11211, 3 ), );
$m = new memcached();
var_dump($m->getServerList());
$m->addServers($servers);
var_dump($m->getServerList());
$m->addServers($servers);
var_dump($m->getServerList());
$m = new memcached();
$m->addServer('127.0.0.1', 11211);
var_dump($m->getServerList());
echo "OK";
?>
--EXPECT--
array(0) {
}
array(1) {
[0]=>
array(3) {
["host"]=>
string(9) "localhost"
["port"]=>
int(11211)
["type"]=>
string(3) "TCP"
}
}
array(2) {
[0]=>
array(3) {
["host"]=>
string(9) "localhost"
["port"]=>
int(11211)
["type"]=>
string(3) "TCP"
}
[1]=>
array(3) {
["host"]=>
string(9) "localhost"
["port"]=>
int(11211)
["type"]=>
string(3) "TCP"
}
}
array(1) {
[0]=>
array(3) {
["host"]=>
string(9) "127.0.0.1"
["port"]=>
int(11211)
["type"]=>
string(3) "TCP"
}
}
OKPK !Y�\���n n tests/incrdecr_initial.phptnu �[��� --TEST--
Memcached::increment() Memcached::decrement() with initial support
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true
));
$m->delete('foo');
var_dump($m->increment('foo', 1, 1));
var_dump($m->increment('foo', 0));
$m->delete('foo');
var_dump($m->increment('foo', 1, 1));
var_dump($m->increment('foo', 1, 1));
var_dump($m->increment('foo', 1, 1));
var_dump($m->decrement('foo', 1, 1));
var_dump($m->decrement('foo', 0));
$m->delete('foo');
$m->deleteByKey('foo', 'foo');
var_dump($m->incrementByKey('foo', 'foo', 1, 1));
var_dump($m->incrementByKey('foo', 'foo', 0));
$m->deleteByKey('foo', 'foo');
var_dump($m->incrementByKey('foo', 'foo', 1, 1));
var_dump($m->incrementByKey('foo', 'foo', 1, 1));
var_dump($m->incrementByKey('foo', 'foo', 1, 1));
var_dump($m->decrementByKey('foo', 'foo', 1, 1));
var_dump($m->decrementByKey('foo', 'foo', 0));
$m->deleteByKey('foo', 'foo');
--EXPECT--
int(1)
int(1)
int(1)
int(2)
int(3)
int(2)
int(2)
int(1)
int(1)
int(1)
int(2)
int(3)
int(2)
int(2)
PK !Y�\_rb�� � tests/callback_exception_2.phptnu �[��� --TEST--
Callback initializer throws and dies
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
function init_cb($m, $id) {
echo "ran throwing cb\n";
var_dump($m->isPersistent());
throw new RuntimeException('Cb exception');
}
function init_cb_die($m, $id) {
echo "ran quitting cb\n";
die("quit in cb");
}
error_reporting(0);
echo "cb with exception\n";
try {
$m1 = new Memcached(null, 'init_cb');
} catch (RuntimeException $e) {
echo $e->getMessage(), "\n";
}
echo "cb persistent with exception\n";
try {
$m2 = new Memcached('foo', 'init_cb');
} catch (RuntimeException $e) {
echo $e->getMessage(), "\n";
}
echo "cb persistent dies\n";
try {
$m3 = new Memcached('bar', 'init_cb_die');
} catch (RuntimeException $e) {
echo $e->getMessage(), "\n";
}
echo "not run\n";
--EXPECT--
cb with exception
ran throwing cb
bool(false)
Cb exception
cb persistent with exception
ran throwing cb
bool(true)
Cb exception
cb persistent dies
ran quitting cb
quit in cb
PK "Y�\R|ы� � tests/types_igbinary_multi.phptnu �[��� --TEST--
Memcached multi store & multi fetch type and value correctness using igbinary serializer
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_IGBINARY) print "skip igbinary not enabled";
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
include dirname (__FILE__) . '/types.inc';
memc_run_test ('memc_types_test_multi',
memc_create_combinations ('igbinary', Memcached::SERIALIZER_IGBINARY)
);
?>
--EXPECT--
TEST DONE
PK #Y�\7�_� � tests/config.incnu �[��� <?php
if (file_exists (dirname (__FILE__) . '/config.inc.local')) {
include dirname (__FILE__) . '/config.inc.local';
}
else {
define ("MEMC_SERVER_HOST", "127.0.0.1");
define ("MEMC_SERVER_PORT", 11211);
//define ("MEMC_SASL_SERVER_HOST", "127.0.0.1");
//define ("MEMC_SASL_SERVER_PORT", 11212);
//define ('MEMC_SASL_USER', 'memcached');
//define ('MEMC_SASL_PASS', 'test');
}
function memc_create_instance ($host, $port, array $opts = array (), $persistent_id = null)
{
$memcached = new Memcached($persistent_id);
if ($memcached->setOptions ($opts) == false)
echo "Failed to set options" . PHP_EOL;
$memcached->addServer($host, $port);
if ($memcached->flush() === false) {
return NULL;
}
return $memcached;
}
function memc_get_instance (array $opts = array (), $persistent_id = null)
{
return memc_create_instance(MEMC_SERVER_HOST, MEMC_SERVER_PORT, $opts, $persistent_id);
}
function memc_get_sasl_instance (array $opts = array (), $persistent_id = null)
{
return memc_create_instance(MEMC_SASL_SERVER_HOST, MEMC_SASL_SERVER_PORT, $opts, $persistent_id);
}
function memc_run_test ($test_function, $options = array ())
{
foreach ($options as $option_set) {
$memc = memc_get_instance ($option_set ['options']);
$test_function ($memc, $option_set);
}
echo "TEST DONE" . PHP_EOL;
}
function memc_create_combinations ($name, $serializer, $ignore_object_type = false)
{
return array (
array (
'title' => "$name serializer, ascii protocol",
'options' => array (
Memcached::OPT_SERIALIZER => $serializer
),
'ignore_object_type' => $ignore_object_type
),
array (
'title' => "$name serializer, binary protocol",
'options' => array (
Memcached::OPT_BINARY_PROTOCOL => true,
Memcached::OPT_SERIALIZER => $serializer
),
'ignore_object_type' => $ignore_object_type
),
);
}
function memc_get_version($memc) {
$version = $memc->getVersion();
return array_pop($version);
}
PK #Y�\��6Y Y tests/memcachedserver.phptnu �[��� --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
PK #Y�\X�-7: : tests/default_behavior.phptnu �[��� --TEST--
Default behaviors
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$m = new Memcached();
var_dump ($m->getOption(Memcached::OPT_DISTRIBUTION) == Memcached::DISTRIBUTION_MODULA);
var_dump ($m->getOption(Memcached::OPT_BINARY_PROTOCOL) == false);
var_dump ($m->getOption(Memcached::OPT_CONNECT_TIMEOUT) != 0);
ini_set('memcached.default_consistent_hash', true);
ini_set('memcached.default_binary_protocol', true);
ini_set('memcached.default_connect_timeout', 1212);
$m = new Memcached();
var_dump ($m->getOption(Memcached::OPT_DISTRIBUTION) == Memcached::DISTRIBUTION_CONSISTENT);
var_dump ($m->getOption(Memcached::OPT_BINARY_PROTOCOL) == true);
var_dump ($m->getOption(Memcached::OPT_CONNECT_TIMEOUT) == 1212);
echo "OK";
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
OK
PK #Y�\}�ޫO O tests/conf_persist.phptnu �[��� --TEST--
Conf settings persist.
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m1 = memc_get_instance (array (
Memcached::OPT_PREFIX_KEY => 'php'
), 'id1');
$m1->set('foo', 'bar');
for ($i = 1000; $i > 0; $i--) {
$m1 = new Memcached('id1');
$rv = $m1->get('foo');
if ($rv !== 'bar') {
echo "Expected bar got:";
var_dump($rv);
die();
}
$prefix = $m1->getOption(Memcached::OPT_PREFIX_KEY);
if ($prefix !== 'php') {
echo "Expected prefix php got:";
var_dump($prefix);
die();
}
}
echo "OK\n";
?>
--EXPECT--
OKPK $Y�\M�hP7 7 tests/setoptions.phptnu �[��� --TEST--
Set options using setOptions
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$m = new Memcached();
/* existing options */
var_dump($m->setOptions(array(
Memcached::OPT_PREFIX_KEY => 'a_prefix',
Memcached::OPT_SERIALIZER => Memcached::SERIALIZER_PHP,
Memcached::OPT_COMPRESSION => 0,
Memcached::OPT_LIBKETAMA_COMPATIBLE => 1,
Memcached::OPT_CONNECT_TIMEOUT => 5000,
)));
var_dump($m->getOption(Memcached::OPT_PREFIX_KEY) == 'a_prefix');
var_dump($m->getOption(Memcached::OPT_SERIALIZER) == Memcached::SERIALIZER_PHP);
var_dump($m->getOption(Memcached::OPT_COMPRESSION) == 0);
var_dump($m->getOption(Memcached::OPT_LIBKETAMA_COMPATIBLE) == 1);
echo "test invalid options\n";
var_dump($m->setOptions(array(
"asdf" => 123
)));
var_dump($m->setOptions(array(
-1 => 123
)));
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
test invalid options
Warning: Memcached::setOptions(): invalid configuration option in %s on line %d
bool(false)
Warning: Memcached::setOptions(): error setting memcached option: %s in %s on line %d
bool(false)
PK $Y�\:+�� � tests/callback_exception.phptnu �[��� --TEST--
make sure that callback exception behaves correctly
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
function throw_something(Memcached $object, $p_id = null)
{
throw new Exception("from cb");
}
function empty_cb(Memcached $object, $p_id = null)
{
echo "empty_cb called\n";
}
try {
$m = new Memcached('test_id', 'throw_something');
echo "fail\n";
} catch (Exception $e) {
echo "success\n";
}
try {
$m = new Memcached('test_id', 'throw_something');
echo "fail\n";
} catch (Exception $e) {
echo "success\n";
}
try {
$m = new Memcached('test_id', 'empty_cb');
$m = new Memcached('test_id', 'empty_cb');
} catch (Exception $e) {
echo "fail\n";
}
try {
$m = new Memcached(null, 'throw_something');
echo "fail\n";
} catch (Exception $e) {
echo "success\n";
}
echo "OK\n";
?>
--EXPECT--
success
success
empty_cb called
success
OK
PK %Y�\p�rpv v tests/session_persistent.phptnu �[��� --TEST--
Session persistent
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) die ('skip session support disabled');
if (Memcached::LIBMEMCACHED_VERSION_HEX < 0x01000018) die ('skip too old libmemcached');
?>
--INI--
session.save_handler=memcached
memcached.sess_persistent=1
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
session_start();
$_SESSION['test']=true;
session_write_close();
session_start();
var_dump($_SESSION);
session_write_close();
?>
--EXPECT--
array(1) {
["test"]=>
bool(true)
}
PK %Y�\2&<�u u tests/check_if_pristine.phptnu �[��� --TEST--
Check if persistent object is new or an old persistent one
--SKIPIF--
<?php include dirname(__FILE__) . "/skipif.inc";
?>
--FILE--
<?php
$m1 = new Memcached('id1');
$m1->setOption(Memcached::OPT_PREFIX_KEY, "foo_");
var_dump($m1->isPristine());
$m1 = new Memcached('id1');
var_dump($m1->isPristine());
$m2 = new Memcached('id1');
var_dump($m2->isPristine());
// this change affects $m1
$m2->setOption(Memcached::OPT_PREFIX_KEY, "bar_");
$m3 = new Memcached('id2');
var_dump($m3->isPristine());
$m3 = new Memcached();
var_dump($m3->isPristine());
--EXPECT--
bool(true)
bool(false)
bool(false)
bool(true)
bool(true)
PK &Y�\e�� tests/prepend.phptnu �[��� --TEST--
Memcached::prepend()
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$m->delete('foo');
$m->setOption(Memcached::OPT_COMPRESSION, true);
var_dump($m->prepend('foo', 'a'));
$m->setOption(Memcached::OPT_COMPRESSION, false);
$m->delete('foo');
var_dump($m->prepend('foo', 'a'));
var_dump($m->get('foo'));
$m->set('foo', 'a');
var_dump($m->prepend('foo', 'b'));
var_dump($m->get('foo'));
--EXPECTF--
Warning: Memcached::prepend(): cannot append/prepend with compression turned on in %s on line %d
NULL
bool(false)
bool(false)
bool(true)
string(2) "ba"
PK &Y�\X�`
tests/version.phptnu �[��� --TEST--
Get version
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
var_dump ($m->getVersion ());
echo "OK" . PHP_EOL;
?>
--EXPECTF--
array(1) {
["%s:%d"]=>
string(%d) "%d.%d.%d"
}
OK
PK &Y�\{6�f" " tests/gh_90.phptnu �[��� --TEST--
Test for GH #90
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$memcached = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true
));
// Create a key for use as a lock. If this key already exists, wait till it doesn't exist.
{
$key = 'LockKey';
$lockToken = mt_rand(0, mt_getrandmax()); //Random value for ownership verification
while (true)
{
$casToken = null;
$data = $memcached->get($key, $casToken);
if ($memcached->getResultCode() == Memcached::RES_NOTFOUND)
{
if ($memcached->add($key, $lockToken, 5))
{
break;
}
}
elseif ($data === false)
{
if ($memcached->cas($casToken, $key, $lockToken, 5))
{
break;
}
}
//Sleep 10 milliseconds
usleep(10 * 1000);
}
}
//Do something here that requires exclusive access to this key
//Effectively delete our key lock.
{
$casToken = null;
if ($lockToken == $memcached->get($key, $casToken))
{
$memcached->cas($casToken, $key, false, 1);
}
}
//Create 10 keys and then increment them. The first value returned will be wrong.
{
$keyList = array();
for ($i = 0; $i < 10; $i++)
{
$keyList[] = $i . '_' . uniqid ('count_value_');
}
$valueList = array();
foreach ($keyList as $key)
{
$valueList[$key] = $memcached->increment($key, 1, 1);
}
var_dump ($valueList);
}
--EXPECTF--
array(10) {
["0_%s"]=>
int(1)
["1_%s"]=>
int(1)
["2_%s"]=>
int(1)
["3_%s"]=>
int(1)
["4_%s"]=>
int(1)
["5_%s"]=>
int(1)
["6_%s"]=>
int(1)
["7_%s"]=>
int(1)
["8_%s"]=>
int(1)
["9_%s"]=>
int(1)
}
PK 'Y�\/��f
tests/server.incnu �[��� <?php
function memcached_server_start($code = 'server.php', $host = "127.0.0.1", $port = 3434) {
$php_executable = getenv('TEST_PHP_EXECUTABLE') ?: PHP_BINARY;
$php_args = getenv('TEST_PHP_ARGS') ?: '';
$descriptorspec = array(
0 => STDIN,
1 => STDOUT,
2 => STDERR,
);
$cmd = "{$php_executable} {$php_args} {$code} {$host}:{$port} ";
if (substr(PHP_OS, 0, 3) == 'WIN') {
$cmd = "{$php_executable} {$php_args} {$code} {$host}:{$port} ";
$handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, __DIR__, NULL, array("bypass_shell" => true, "suppress_errors" => true));
} else {
$cmd = "exec {$cmd} 2>/dev/null";
$handle = proc_open($cmd, $descriptorspec, $pipes, __DIR__);
}
// note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.'
// it might not be listening yet...need to wait until fsockopen() call returns
$error = "Unable to connect to server\n";
for ($i=0; $i < getenv("VALGRIND") ? 1000 : 60; $i++) {
usleep(50000); // 50ms per try
$status = proc_get_status($handle);
$fp = @fsockopen($host, $port);
// Failure, the server is no longer running
if (!($status && $status['running'])) {
$error = "Server is not running {$status['command']}\n";
break;
}
// Success, Connected to servers
if ($fp) {
$error = '';
break;
}
}
if ($fp) {
fclose($fp);
}
if ($error) {
echo $error;
proc_terminate($handle);
proc_close($handle);
exit(1);
}
register_shutdown_function(
function($handle) {
if (is_resource($handle)) {
proc_terminate($handle);
proc_close($handle);
}
},
$handle
);
return $handle;
}
function memcached_server_stop($handle) {
$success = FALSE;
if ($handle) {
proc_terminate($handle);
/* Wait for server to shutdown */
for ($i = 0; $i < 60; $i++) {
$status = proc_get_status($handle);
if (!($status && $status['running'])) {
$success = TRUE;
break;
}
usleep(50000);
}
proc_close($handle);
}
return $success;
}
PK 'Y�\2��� � tests/bad_construct_8.phptnu �[��� --TEST--
Memcached construct with bad arguments
--SKIPIF--
<?php
include "skipif.inc";
if (PHP_VERSION_ID < 80000) die("skip PHP 8 only");
?>
--FILE--
<?php
try {
$m = new Memcached((object)array());
} catch (TypeError $e) {
echo $e->getMessage() . PHP_EOL;
}
class extended extends Memcached {
public function __construct () {
}
}
error_reporting(E_ALL);
try {
$extended = new extended ();
var_dump ($extended->setOption (Memcached::OPT_BINARY_PROTOCOL, true));
} catch (Error $e) {
echo $e->getMessage() . PHP_EOL;
}
echo "OK" . PHP_EOL;
--EXPECTF--
Memcached::__construct(): Argument #1 ($persistent_id) must be of type ?string, stdClass given
Memcached constructor was not called
OK
PK (Y�\���e e tests/invoke_callback_twice.phptnu �[��� --TEST--
Test that callback is invoked on new object only once
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
function my_func(Memcached $obj, $persistent_id = null)
{
echo "Invoked for '{$persistent_id}'\n";
}
$m1 = new Memcached('foobar', 'my_func');
$m2 = new Memcached('foobar', 'my_func');
echo "OK\n";
--EXPECT--
Invoked for 'foobar'
OK
PK (Y�\�XF�� � tests/get_flags.phptnu �[��� --TEST--
Memcached::get/getMulti() flags
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$key1 = uniqid('memc.test.');
$key2 = uniqid('memc.test.');
$m->set ($key1, 'hello1', 20);
$m->set ($key2, 'hello2', 20);
$value = $m->get($key1);
$extended = $m->get($key1, null, Memcached::GET_EXTENDED);
var_dump ($value);
var_dump ($extended);
$values = $m->getMulti(array ($key1, $key2), Memcached::GET_PRESERVE_ORDER);
$extended = $m->getMulti(array ($key1, $key2), Memcached::GET_EXTENDED | Memcached::GET_PRESERVE_ORDER);
var_dump ($values);
var_dump ($extended);
echo "OK";
--EXPECTF--
string(6) "hello1"
array(3) {
["value"]=>
string(6) "hello1"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}
array(2) {
["memc.test.%s"]=>
string(6) "hello1"
["memc.test.%s"]=>
string(6) "hello2"
}
array(2) {
["memc.test.%s"]=>
array(3) {
["value"]=>
string(6) "hello1"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}
["memc.test.%s"]=>
array(3) {
["value"]=>
string(6) "hello2"
["cas"]=>
int(%d)
["flags"]=>
int(0)
}
}
OKPK )Y�\����� � tests/session_basic3.phptnu �[��� --TEST--
Session basic open, write, destroy
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
?>
--INI--
session.save_handler = memcached
memcached.sess_binary_protocol = Off
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
ob_start();
session_start();
$_SESSION['foo'] = 1;
session_write_close();
$_SESSION = NULL;
var_dump($_SESSION);
session_start([
'read_and_close' => true
]);
var_dump($_SESSION);
session_write_close();
session_start();
session_destroy();
session_start();
var_dump($_SESSION);
session_write_close();
--EXPECT--
NULL
array(1) {
["foo"]=>
int(1)
}
array(0) {
}
PK )Y�\#��� � tests/incrdecr_bykey.phptnu �[��� --TEST--
Memcached::incrementByKey() Memcached::decrementByKey()
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
echo "Not there\n";
$m->delete('foo');
var_dump($m->incrementByKey('foo', 'foo', 1));
var_dump($m->decrementByKey('foo', 'foo', 1));
var_dump($m->get('foo'));
echo "Normal\n";
$m->set('foo', 1);
var_dump($m->get('foo'));
$m->incrementByKey('foo', 'foo');
var_dump($m->get('foo'));
$m->incrementByKey('foo', 'foo', 2);
var_dump($m->get('foo'));
$m->decrementByKey('foo', 'foo');
var_dump($m->get('foo'));
$m->decrementByKey('foo', 'foo', 2);
var_dump($m->get('foo'));
error_reporting(0);
echo "Negative offset\n";
error_clear_last();
$m->incrementByKey('foo', 'foo', -1);
echo error_get_last()["message"], "\n";
var_dump($m->get('foo'));
error_clear_last();
$m->decrementByKey('foo', 'foo', -1);
echo error_get_last()["message"], "\n";
var_dump($m->get('foo'));
echo "Enormous offset\n";
$m->incrementByKey('foo', 'foo', 0x7f000000);
var_dump($m->get('foo'));
$m->decrementByKey('foo', 'foo', 0x7f000000);
var_dump($m->get('foo'));
--EXPECT--
Not there
bool(false)
bool(false)
bool(false)
Normal
int(1)
int(2)
int(4)
int(3)
int(1)
Negative offset
Memcached::incrementByKey(): offset cannot be a negative value
int(1)
Memcached::decrementByKey(): offset cannot be a negative value
int(1)
Enormous offset
int(2130706433)
int(1)
PK *Y�\���� � tests/cas.phptnu �[��� --TEST--
Memcached fetch cas & set cas
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$m->delete('cas_test');
$m->set('cas_test', 'hello');
$cas_token = $m->get('cas_test', null, Memcached::GET_EXTENDED)['cas'];
$v = $m->cas($cas_token, 'cas_test', 0);
if ($v != true) {
echo "CAS failed";
}
echo "OK\n";
?>
--EXPECT--
OKPK *Y�\n�;P P tests/vbucket_error_8.phptnu �[��� --TEST--
Memcached virtual buckets
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!defined("Memcached::DISTRIBUTION_VIRTUAL_BUCKET")) die ("skip DISTRIBUTION_VIRTUAL_BUCKET not defined");
if (PHP_VERSION_ID < 80000) die("skip PHP 8 only");
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance (array (
Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_VIRTUAL_BUCKET
));
var_dump ($m->setBucket (array (), null, 2));
var_dump ($m->setBucket (array (), array (), -1));
try {
var_dump ($m->setBucket (null, array (), -1));
} catch (TypeError $e) {
echo $e->getMessage() . PHP_EOL;
}
var_dump ($m->setBucket (array (-1), array (-1), 1));
echo "OK\n";
?>
--EXPECTF--
Warning: Memcached::setBucket(): server map cannot be empty in %s on line %d
bool(false)
Warning: Memcached::setBucket(): server map cannot be empty in %s on line %d
bool(false)
Memcached::setBucket(): Argument #1 ($host_map) must be of type array, null given
Warning: Memcached::setBucket(): the map must contain positive integers in %s on line %d
bool(false)
OK
PK +Y�\M�<�� � tests/session_basic2.phptnu �[��� --TEST--
Session basic open, write, destroy
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
?>
--INI--
session.save_handler = memcached
memcached.sess_binary_protocol = Off
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
ob_start();
session_start(['lazy_write'=>TRUE]);
$_SESSION['foo'] = 1;
session_write_close();
$_SESSION = NULL;
var_dump($_SESSION);
session_start();
var_dump($_SESSION);
session_write_close();
session_start();
session_destroy();
session_start();
var_dump($_SESSION);
session_write_close();
--EXPECT--
NULL
array(1) {
["foo"]=>
int(1)
}
array(0) {
}
PK +Y�\�Q*@� � % tests/session_badconf_persistent.phptnu �[��� --TEST--
Session bad configurations, persistent
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
?>
--INI--
session.save_handler = "memcached"
session.save_path = "PERSISTENT=1 hello:11211,world:11211"
--FILE--
<?php
ob_start();
session_start();
session_write_close();
// In PHP < 7.2 this is a Fatal Error so the OK is not printed
// echo "OK";
--EXPECTF--
Warning: session_start(): failed to parse session.save_path: PERSISTENT is replaced by memcached.sess_persistent = On in %s on line %d
%s: session_start(): Failed to initialize storage module: memcached (path: PERSISTENT=1 %s) in %s on line %d
PK ,Y�\ zAL� � tests/cas_multi.phptnu �[��� --TEST--
Memcached multi fetch cas & set cas
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$data = array(
'cas_test_1' => 1,
'cas_test_2' => 2,
);
foreach ($data as $key => $v) {
$m->delete($key);
}
$m->setMulti($data, 10);
$actual = $m->getMulti(array_keys($data), Memcached::GET_EXTENDED);
foreach ($actual as $key => $v) {
if (is_null($v['cas'])) {
echo "missing cas token(s)\n";
echo "data: ";
var_dump($data);
echo "actual data: ";
var_dump($actual);
return;
}
$v = $m->cas($v['cas'], $key, 11);
if (!$v) {
echo "Error setting key: $key value: 11 with CAS: ", $v['cas'], "\n";
return;
}
$v = $m->get($key);
if ($v !== 11) {
echo "Wanted $key to be 11, value is: ";
var_dump($v);
return;
}
}
if (array_keys($actual) !== array_keys($data)) {
echo "missing value(s)\n";
echo "data :";
var_dump($data);
echo "actual data: ";
var_dump($actual);
return;
}
echo "OK\n";
?>
--EXPECT--
OKPK ,Y�\�
.s s tests/vbucket.phptnu �[��� --TEST--
Memcached virtual buckets
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!defined("Memcached::DISTRIBUTION_VIRTUAL_BUCKET")) die ("skip DISTRIBUTION_VIRTUAL_BUCKET not defined");
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance (array (
Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_VIRTUAL_BUCKET
));
var_dump ($m->setBucket (array (1, 2, 3), null, 2));
var_dump ($m->setBucket (array (1,2,2), array (1,2,2), 2));
var_dump ($m->setBucket (array ('a', 'b', 'c'), null, 2));
echo "OK\n";
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
OK
PK -Y�\"�f tests/rescode.phptnu �[��� --TEST--
Memcached result codes.
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = new Memcached();
echo $m->getResultMessage(), "\n";
$m->addServer(MEMC_SERVER_HOST, MEMC_SERVER_PORT, 1);
echo $m->getResultCode(), "\n";
echo $m->getResultMessage(), "\n";
$m->set('bar_foo', 10);
echo $m->getResultMessage(), "\n";
$m->delete('bar_foo');
echo $m->getResultMessage(), "\n";
$m->delete('bar_foo');
echo $m->getResultCode(), "\n";
echo $m->getResultMessage(), "\n";
$m->set ('asdf_a', 'aa');
$m->getMulti(array('asdf_a', 'jkhjkhjkb', 'nbahsdgc'));
echo $m->getResultMessage(), "\n";
$code = $m->getResultCode();
$m2 = new Memcached();
$m2->getMulti(array('asdf_a', 'jkhjkhjkb', 'nbahsdgc'));
echo $m2->getResultCode(), "\n";
echo $m2->getResultMessage(), "\n";
$m2->addServer('127.0.0.1', 7312, 1);
echo $m2->getResultCode(), "\n";
echo $m2->getResultMessage(), "\n";
$m2->delete('bar_foo');
echo $m2->getResultCode(), "\n";
echo $m2->getResultMessage(), "\n";
var_dump($m->getResultCode() == $code);
$m = memc_get_instance (array (), 'test1');
$m2 = new Memcached('test1');
$m->delete('moikkamitakuuluu');
echo $m->getResultMessage(), "\n";
$m2->set('minapaasetannih', 10, 1);
echo $m->getResultMessage(), "\n";
echo $m2->getResultMessage(), "\n";
$m->delete('bar_foo');
// clearly "NOT FOUND"
$m->delete('bar_foo');
$res_m = $m->getResultMessage();
echo $res_m, "\n";
$m2->set('bar_foo', 10);
echo $m->getResultMessage(), "\n";
echo $m2->getResultMessage(), "\n";
$m->delete('bar_foo');
echo $m->getResultMessage(), "\n";
?>
--EXPECTF--
SUCCESS
%d
SUCCESS
SUCCESS
SUCCESS
%d
NOT FOUND
SUCCESS
%d
NO SERVERS DEFINED
%d
SUCCESS
%d
%rSYSTEM ERROR|WRITE FAILURE|CONNECTION FAILURE%r
bool(true)
NOT FOUND
NOT FOUND
SUCCESS
NOT FOUND
NOT FOUND
SUCCESS
SUCCESS
PK -Y�\���Ed d tests/invalid_options.phptnu �[��� --TEST--
Get version
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$m->setOption(500, 23423);
var_dump ($m->getResultCode ());
echo "OK" . PHP_EOL;
?>
--EXPECTF--
Warning: Memcached::setOption(): error setting memcached option: INVALID ARGUMENTS in %s on line %d
int(38)
OKPK .Y�\�|��\ \ tests/types_php.phptnu �[��� --TEST--
Memcached store & fetch type and value correctness using PHP serializer
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
include dirname (__FILE__) . '/types.inc';
memc_run_test ('memc_types_test',
memc_create_combinations ('PHP', Memcached::SERIALIZER_PHP)
);
?>
--EXPECT--
TEST DONE
PK .Y�\,�r�� � tests/invoke_callback_2.phptnu �[��� --TEST--
Use callback initializer
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$arg = 'callback_arg';
$id = 'my_persistent_id';
function init_cb($m, $id) {
var_dump(get_class($m));
var_dump($m->isPersistent());
var_dump($id);
}
function init_cb_fail($m, $id) {
echo "configured, should not be called.\n";
}
function init_cb_arg($m, $id) {
var_dump(func_num_args());
var_dump($id);
}
function init_nopersist_cb($m, $id) {
var_dump($m->isPersistent());
var_dump($id);
}
class Foo extends Memcached {
function __construct($id = null) {
parent::__construct($id, array($this, 'init'));
}
function init($obj, $id) {
var_dump(func_num_args());
var_dump($this->isPristine());
var_dump($this->isPersistent());
var_dump($id);
}
}
echo "cb call\n";
$m1 = new Memcached('foo1', 'init_cb');
echo "cb not run\n";
$m1 = new Memcached('foo1', 'init_cb_fail');
echo "cb arg without arg\n";
$m1 = new Memcached('foo3', 'init_cb_arg');
echo "cb arg not persistent\n";
$m1 = new Memcached(null, 'init_nopersist_cb');
echo "cb in object\n";
$m1 = new Foo();
echo "cb persistent in object\n";
$m1 = new Foo('baz');
echo "cb second persistent in object\n";
$m1 = new Foo('baz');
?>
--EXPECT--
cb call
string(9) "Memcached"
bool(true)
string(4) "foo1"
cb not run
cb arg without arg
int(2)
string(4) "foo3"
cb arg not persistent
bool(false)
NULL
cb in object
int(2)
bool(true)
bool(false)
NULL
cb persistent in object
int(2)
bool(true)
bool(true)
string(3) "baz"
cb second persistent in object
PK /Y�\�x�
�
tests/memcachedserver6.phptnu �[��� --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");
}
?>
--FILE--
<?php
include __DIR__ . '/server.inc';
$server = memcached_server_start('server.php', '[::1]', 3434);
$cache = new Memcached();
$cache->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$cache->setOption(Memcached::OPT_COMPRESSION, false);
$cache->addServer('[::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 [::1]:3434
Incoming connection from [::1]:%s
Incoming connection from [::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) {
["[::1]:3434"]=>
string(5) "1.1.1"
}
client_id=[%s]: Stat key=[]
array(1) {
["[::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) {
["[::1]:3434"]=>
array(2) {
["key"]=>
string(6) "foobar"
["foo"]=>
string(3) "bar"
}
}
client_id=[%s]: Stat key=[scalar]
array(1) {
["[::1]:3434"]=>
array(1) {
[0]=>
string(%d) "you want it, you get it"
}
}
client_id=[%s]: Stat key=[numeric array]
array(1) {
["[::1]:3434"]=>
array(3) {
[-1]=>
string(3) "one"
[0]=>
string(3) "two"
[1]=>
string(5) "three"
}
}
client_id=[%s]: Client quit
Done
PK /Y�\
�n� � tests/001.phptnu �[��� --TEST--
Check for memcached presence
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
echo "memcached extension is available";
?>
--EXPECT--
memcached extension is available
PK 0Y�\�^� tests/invoke_callback.phptnu �[��� --TEST--
Test that callback is invoked on new object
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
function my_func(Memcached $obj, $persistent_id = null)
{
$obj->addServer(MEMC_SERVER_HOST, MEMC_SERVER_PORT);
}
$m = new Memcached('hi', 'my_func');
$m = new Memcached('hi', 'my_func');
var_dump($m->getServerList());
echo "OK\n";
--EXPECTF--
array(1) {
[0]=>
array(3) {
["host"]=>
string(9) "%s"
["port"]=>
int(%d)
["type"]=>
string(3) "TCP"
}
}
OK
PK 0Y�\n
t�� � tests/check_key.phptnu �[��� --TEST--
Memcached::checkKey()
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => false,
Memcached::OPT_VERIFY_KEY => true
));
$keys = [
'foo',
'foo bar',
str_repeat('a',65),
str_repeat('b',250),
str_repeat('c',251),
'Montréal',
'København',
'Düsseldorf',
'Kraków',
'İstanbul',
'ﺎﺨﺘﺑﺍﺭ PHP',
'測試',
'Тестирование',
'پی ایچ پی کی جانچ ہو رہی ہے',
'Testataan PHP: tä',
'Að prófa PHP',
'د پی ایچ پی ازمول',
'Pruvà PHP'
];
foreach($keys as $key) {
echo "Checking \"$key\"" . PHP_EOL;
echo "MEMC_CHECK_KEY: ";
var_dump($m->checkKey($key));
echo "libmemcached: ";
var_dump($m->set($key, "this is a test"));
var_dump($m->getResultMessage());
echo "\n";
}
--EXPECT--
Checking "foo"
MEMC_CHECK_KEY: bool(true)
libmemcached: bool(true)
string(7) "SUCCESS"
Checking "foo bar"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
MEMC_CHECK_KEY: bool(true)
libmemcached: bool(true)
string(7) "SUCCESS"
Checking "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
MEMC_CHECK_KEY: bool(true)
libmemcached: bool(true)
string(7) "SUCCESS"
Checking "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "Montréal"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "København"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "Düsseldorf"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "Kraków"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "İstanbul"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "ﺎﺨﺘﺑﺍﺭ PHP"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "測試"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "Тестирование"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "پی ایچ پی کی جانچ ہو رہی ہے"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "Testataan PHP: tä"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "Að prófa PHP"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "د پی ایچ پی ازمول"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
Checking "Pruvà PHP"
MEMC_CHECK_KEY: bool(false)
libmemcached: bool(false)
string(46) "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE"
PK 1Y�\�3=a� � tests/cachecallback.phptnu �[��� --TEST--
Memcached::get() with cache callback
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$runs = 0;
$first_key = uniqid ('cache_test_');
$second_key = uniqid ('cache_test_');
$third_key = uniqid ('cache_test_');
$m->delete($first_key);
$m->delete($second_key);
$m->delete($third_key);
var_dump (
$m->get ($first_key, function (Memcached $memc, $key, &$value, &$expiration) {
$value = "hello";
$expiration = 10;
return true;
})
);
var_dump ($m->get ($first_key));
var_dump (
$m->get ($second_key, function (Memcached $memc, $key, &$value, &$expiration) {
$value = "hello";
$expiration = 10;
return false;
})
);
var_dump ($m->get ($second_key));
try {
$m->get ($third_key, function (Memcached $memc, $key, &$value, &$expiration) {
$value = "hello";
$expiration = 10;
throw new Exception ('this is a test');
return true;
});
} catch (Exception $e) {
echo 'Got exception' . PHP_EOL;
}
var_dump ($m->get ($third_key));
echo "OK" . PHP_EOL;
--EXPECT--
string(5) "hello"
string(5) "hello"
bool(false)
bool(false)
Got exception
bool(false)
OKPK 1Y�\�Ɂ�3 3 tests/options.phptnu �[��� --TEST--
Memcached options
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$m = new Memcached();
$m->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_PHP);
var_dump($m->getOption(Memcached::OPT_COMPRESSION));
var_dump($m->getOption(Memcached::OPT_SERIALIZER));
var_dump($m->getOption(Memcached::OPT_SOCKET_SEND_SIZE));
$m->setOption(Memcached::OPT_PREFIX_KEY, "\x01");
var_dump($m->getOption(Memcached::OPT_HASH) == Memcached::HASH_DEFAULT);
$m->setOption(Memcached::OPT_HASH, Memcached::HASH_MURMUR);
var_dump($m->getOption(Memcached::OPT_HASH) == Memcached::HASH_MURMUR);
$m->setOption(Memcached::OPT_COMPRESSION_TYPE, Memcached::COMPRESSION_ZLIB);
var_dump($m->getOption(Memcached::OPT_COMPRESSION_TYPE) == Memcached::COMPRESSION_ZLIB);
$m->setOption(Memcached::OPT_COMPRESSION_TYPE, Memcached::COMPRESSION_FASTLZ);
var_dump($m->getOption(Memcached::OPT_COMPRESSION_TYPE) == Memcached::COMPRESSION_FASTLZ);
var_dump($m->setOption(Memcached::OPT_COMPRESSION_TYPE, 0));
var_dump($m->getOption(Memcached::OPT_COMPRESSION_TYPE) == Memcached::COMPRESSION_FASTLZ);
?>
--EXPECTF--
bool(true)
int(1)
Warning: Memcached::getOption(): no servers defined in %s on line %d
NULL
Warning: Memcached::setOption(): bad key provided in %s on line %d
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(true)
PK 2Y�\RU�C # tests/session_badconf_locktime.phptnu �[��� --TEST--
Session bad configurations, lock wait time
--SKIPIF--
<?php include dirname(__FILE__) . "/skipif.inc";
print "skip skip until timeout in memcached set"
?>
--INI--
memcached.sess_locking = on
memcached.sess_lock_wait = -1
memcached.sess_prefix = "memc.sess.key."
session.save_path="127.0.0.1:51312"
session.save_handler = memcached
--FILE--
<?php
error_reporting(0);
function handler($errno, $errstr) {
echo "$errstr\n";
}
set_error_handler('handler', E_ALL);
session_start();
session_write_close();
echo "OK\n";
--EXPECTF--
OKPK 3Y�\�R tests/reset_keyprefix.phptnu �[��� --TEST--
Cannot reset OPT_PREFIX_KEY #293
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
$m->set('key1', 'abc');
var_dump($m->get('key1'));
$m->setOption(Memcached::OPT_PREFIX_KEY, 'prefix');
var_dump($m->get('key1'));
$m->setOption(Memcached::OPT_PREFIX_KEY, false);
var_dump($m->get('key1'));
$m->setOption(Memcached::OPT_PREFIX_KEY, 'prefix');
var_dump($m->get('key1'));
$m->setOption(Memcached::OPT_PREFIX_KEY, '');
var_dump($m->get('key1'));
$m->setOption(Memcached::OPT_PREFIX_KEY, 'prefix');
var_dump($m->get('key1'));
$m->setOption(Memcached::OPT_PREFIX_KEY, null);
var_dump($m->get('key1'));
--EXPECTF--
string(3) "abc"
bool(false)
string(3) "abc"
bool(false)
string(3) "abc"
bool(false)
string(3) "abc"PK 3Y�\;E�+� � tests/pr_75.phptnu �[��� --TEST--
Wrong return values for binary protocol
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$client = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true
));
$client->set('key1', 'value1');
echo "set result code: ".$client->getResultCode()."\n";
$value = $client->get('key1');
echo "got $value with result code: ".$client->getResultCode()."\n";
var_dump ($client->add('key2', 'value2'));
echo "add result code: ".$client->getResultCode()."\n";
echo "OK\n";
?>
--EXPECT--
set result code: 0
got value1 with result code: 0
bool(true)
add result code: 0
OKPK 3Y�\V��� � tests/construct.phptnu �[��� --TEST--
Memcached constructor
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$m = new Memcached();
echo get_class($m);
?>
--EXPECT--
Memcached
PK 4Y�\�e��� � tests/bug_18639.phptnu �[��� --TEST--
Memcached::getServerByKey(): Bug pecl#18639 (Segfault in getServerByKey)
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = memc_get_instance ();
var_dump($m->set('test', 'test1'));
var_dump($m->getServerByKey('1'));
--EXPECTF--
bool(true)
array(3) {
["host"]=>
string(9) "%s"
["port"]=>
int(%d)
["weight"]=>
int(%r[01]%r)
}
PK 4Y�\��;� � tests/bug_17137.phptnu �[��� --TEST--
Change prefix, pecl bug #17137
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$memcache = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true,
Memcached::OPT_PREFIX_KEY => 'prefix1',
));
$memcache2 = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true,
Memcached::OPT_PREFIX_KEY => 'prefix2',
));
var_dump($memcache->getOption(Memcached::OPT_PREFIX_KEY));
var_dump($memcache->set('test', "val_prefix1", 120));
var_dump($memcache->get('test'));
var_dump($memcache2->getOption(Memcached::OPT_PREFIX_KEY));
var_dump($memcache2->set('test', "val_prefix2", 120));
var_dump($memcache2->get('test'));
var_dump($memcache->get('test'));
--EXPECT--
string(7) "prefix1"
bool(true)
string(11) "val_prefix1"
string(7) "prefix2"
bool(true)
string(11) "val_prefix2"
string(11) "val_prefix1"
PK 5Y�\�e2�V V tests/session_lock-php71.phptnu �[��� --TEST--
Session lock
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
if (PHP_VERSION_ID < 70100) print "skip";
?>
--INI--
memcached.sess_locking = true
memcached.sess_lock_wait_min = 500
memcached.sess_lock_wait_max = 1000
memcached.sess_lock_retries = 3
memcached.sess_prefix = "memc.test."
# Turn off binary protocol while the test matrix has older versions of
# libmemcached for which the extension warns of a broken touch command.
memcached.sess_binary_protocol = Off
session.save_handler = memcached
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$m = new Memcached();
$m->addServer(MEMC_SERVER_HOST, MEMC_SERVER_PORT);
ob_start();
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
session_start();
$session_id = session_id();
$_SESSION["test"] = "hello";
session_write_close();
session_start();
var_dump ($m->get ('memc.test.' . session_id()));
var_dump ($m->get ('memc.test.lock.' . session_id()));
session_write_close();
var_dump ($m->get ('memc.test.lock.' . session_id()));
// Test lock min / max
$m->set ('memc.test.lock.' . $session_id, '1');
$time_start = microtime(true);
session_start();
$time = microtime(true) - $time_start;
if (round ($time, 1) != 2.5) {
echo "Waited longer than expected: $time" . PHP_EOL;
}
echo "OK";
--EXPECTF--
string(17) "test|s:5:"hello";"
string(1) "1"
bool(false)
Warning: session_start(): Unable to clear session lock record in %s on line %d
Warning: session_start(): Failed to read session data: memcached (path: 127.0.0.1:11211) in %s on line %d
OK
PK 6Y�\�� � tests/types.incnu �[��� <?php
class testclass {
}
function memc_types_test ($m, $options)
{
$data = array(
array('boolean_true', true),
array('boolean_false', false),
array('string', "just a string"),
array('string_empty', ""),
array('integer_positive_integer', 10),
array('integer_negative_integer', -10),
array('integer_zero_integer', 0),
array('float_positive1', 3.912131),
array('float_positive2', 1.2131E+501),
array('float_positive2', 1.2131E+52),
array('float_negative', -42.123312),
array('float_zero', 0.0),
array('null', null),
array('array_empty', array()),
array('array', array(1,2,3,"foo")),
array('object_array_empty', (object)array()),
array('object_array', (object)array("a" => "1","b" => "2","c" => "3")),
array('object_dummy', new testclass()),
);
foreach ($data as $key => $value) {
$m->delete($key);
}
foreach ($data as $types) {
$key = $types [0];
$value = $types [1];
$m->set($key, $value);
$actual = $m->get($key);
if ($value !== $actual) {
if (is_object($actual)) {
if ($options['ignore_object_type']) {
$value = (object) (array) $value;
if ($value == $actual)
continue;
}
if ($value == $actual && get_class($value) == get_class($actual))
continue;
}
echo "=== {$key} ===\n";
echo "Expected: ";
var_dump($value);
echo "Actual: ";
var_dump($actual);
}
}
$m->flush();
if (($actual = $m->get(uniqid ('random_key_'))) !== false) {
echo "Expected: null";
echo "Actual: " . gettype($actual);
}
}
function memc_types_test_multi ($m, $options)
{
$data = array(
'boolean_true' => true,
'boolean_false' => false,
'string' => "just a string",
'string_empty' => "",
'string_large' => str_repeat ('abcdef0123456789', 500),
'integer_positive_integer' => 10,
'integer_negative_integer' => -10,
'integer_zero_integer' => 0,
'float_positive1' => 3.912131,
'float_positive2' => 1.2131E+52,
'float_negative' => -42.123312,
'float_zero' => 0.0,
'null' => null,
'array_empty' => array(),
'array' => array(1,2,3,"foo"),
'object_array_empty' => (object)array(),
'object_array' => (object)array('a' => 1, 'b' => 2, 'c' => 3),
'object_dummy' => new testclass(),
);
foreach ($data as $key => $value) {
$m->delete($key);
}
$m->setMulti($data);
$actual = $m->getMulti(array_keys($data));
foreach ($data as $key => $value) {
if ($value !== $actual[$key]) {
if (is_object($value)) {
if ($options['ignore_object_type']) {
$value = (object) (array) $value;
if ($value == $actual[$key])
continue;
}
if ($value == $actual[$key] && get_class($value) == get_class($actual[$key]))
continue;
}
echo "=== $key ===\n";
echo "Expected: ";
var_dump($value);
echo "Actual: ";
var_dump($actual[$key]);
}
}
}
PK 6Y�\��ݫ ( tests/session_badconf_servers-php72.phptnu �[��� --TEST--
Session bad configurations, invalid save path (server list)
--SKIPIF--
<?php
include dirname(__FILE__) . "/skipif.inc";
if (!Memcached::HAVE_SESSION) print "skip";
if (PHP_VERSION_ID < 70200) print "skip";
?>
--INI--
session.save_handler = memcached
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
error_reporting(0);
function handler($errno, $errstr) {
echo "$errstr\n";
}
set_error_handler('handler', E_ALL);
ini_set('memcached.sess_prefix', 'memc.sess.key.');
ini_set('session.save_path', '');
session_start();
session_write_close();
--EXPECT--
session_start(): failed to parse session.save_path
session_start(): Failed to initialize storage module: memcached (path: )
PK 7Y�\tk�^ ^ tests/expire.phptnu �[��� --TEST--
Memcached store, fetch & touch expired key
--SKIPIF--
<?php
$min_version = "1.4.8";
include dirname(__FILE__) . "/skipif.inc";
if (!method_exists("memcached", "touch")) die ("skip memcached::touch is not available");
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
function run_expiry_test ($m) {
$key = uniqid ('will_expire_');
$set = $m->set($key, "foo", 2);
$v = $m->get($key);
if (!$set || $v != 'foo') {
echo "Error setting key to \"foo\" with 2s expiry.\n";
return;
}
sleep(1);
$res = $m->touch($key, 2);
$v = $m->get($key);
if(!$res || $v != 'foo') {
echo "Error touching key for another 2s expiry.\n";
var_dump($res);
var_dump($m->getResultMessage());
var_dump($v);
return;
}
sleep(3);
$v = $m->get($key);
if ($v !== Memcached::GET_ERROR_RETURN_VALUE) {
echo "Wanted:\n";
var_dump(Memcached::GET_ERROR_RETURN_VALUE);
echo "from get of expired value. Got:\n";
var_dump($v);
return;
}
echo "All OK" . PHP_EOL;
}
$m = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true
));
echo '-- binary protocol' . PHP_EOL;
run_expiry_test ($m);
$m = memc_get_instance ();
echo '-- text protocol' . PHP_EOL;
run_expiry_test ($m);
echo "DONE TEST\n";
?>
--EXPECT--
-- binary protocol
All OK
-- text protocol
All OK
DONE TEST
PK 7Y�\\��u u &