复代码 代码如下:
$memcachehost = 'localhost';
$memcacheport = '11211';
function microtime_float(){
list($usec, $sec) = 폭발(" ", microtime());
return ((float)$usec (float)$sec);
}
함수 런타임($t1){
return number_format((microtime_float() - $t1)*1000, 4).'ms';
}
$starttime = microtime_float();
$cache_time = '30';
echo "init=====".runtime($starttime).'
';
$sql = "SELECT * FROM hx WHERE ID = 10006";
$mem_sql_key = md5($sql);
$t1 = microtime_float();
echo "APC_read=====";
$arrs = apc_fetch($mem_sql_key);
에코 런타임($t1).'
';
$t1 = microtime_float();
apc_store($mem_sql_key.'_test', $arrs, $cache_time);
echo "APC_write=====";
에코 런타임($t1).'
';
$t1 = microtime_float();
$mem = 새로운 Memcache;
$mem->connect($memcachehost, $memcacheport);
echo "MEM_c
$t1 = microtime_float();
$arrs = $mem->get($mem_sql_key);
echo "MEM_read=====";
echo 런타임($t1).'
';
$t1 = microtime_float()
$mem->set($mem_sql_key.'_test',$arrs,0,$cache_time)
echo "MEM_write=====";
echo 런타임($t1).'
'
?>