1 Star 0 Fork 0

ryanduan/php-memcached

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
session_lock.phpt 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
--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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rczweb_admin/php-memcached.git
git@gitee.com:rczweb_admin/php-memcached.git
rczweb_admin
php-memcached
php-memcached
master

搜索帮助