您好,欢迎来到码863代码分享网! 请[登录] / [注册]

原生apcu与redis 和thinkphp6.0.9下的apcu与redis速度对比

编辑

都写10万次

原生apcu最快0.018秒 原生redis1.8秒

thinkphp6框架内

apcu最快0.035秒 原生redis1.9秒 

$a=$_GET['a'];
$b=(int)$_GET['b'];
$redis = new Redis();
define('ENTRY',microtime(true));
if($a=='1'){
	$res=$redis->pconnect('127.0.0.1', '6379', 0, 'persistent_id_0');
	$redis->set('aaaa','aaaa');
	$i=0;
	while($i++<$b)$redis->set('aaaa',$i);
	echo $redis->get('aaaa');
}else{
	apcu_add('aaaa','aaaa');
	$i=0;
	while($i++<$b)apcu_store('aaaa',$i);	
	echo apcu_fetch('aaaa');

}
echo '<br>'.number_format(microtime(true)-ENTRY,9);


namespace think;
define('DEBUG',true);//为了规范程序不建议用它    程序内都用app->isDebug
apcu_clear_cache();
define('ENTRY',microtime(true));
require __DIR__ . '/../vendor/autoload.php';
// 执行HTTP应用并响应

$app = new App();
$store=$app->cache->store('apcu');
$store->set('aaaa','aaaa');
$i=0;
$a=$_GET['a'];
$b=(int)$_GET['b'];
while($i++<$b)$store->set('aaaa',$i);
echo $store->get('aaaa');
echo '<br>'.number_format(microtime(true)-ENTRY,9);


CopyRight 2002~2023 精通2100网 联系邮箱:qqtxt@163.com
版权所有:精通2100网 湘ICP备2023018646号-1
MYSQl共执行 3 个查询,用时 0.52355217933655 秒,PHP脚本用时 0.526471 秒,占用内存 0.498 MB,Gzip 已启用