都写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);