1 Star 0 Fork 0

ryanduan/php-memcached

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

搜索帮助