时间:2021-07-01 10:21:17 帮助过:4人阅读

function getTimeStamp() {
$timestr = microtime();
$timestrary = explode(' ', $timestr);
$result = intval($timestrary[1])*1000 + intval(floatval($timestrary[0])*1000);
return $result;
}
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$key = 'key';
$value ='value';
$redis->set($key, $value);
apc_store($key, $value, 1);
$begin = getTimeStamp();
for($i = 0 ; $i < 100000 ; $i = $i +1) {
$result = apc_fetch($key);
}
$cost = getTimeStamp() - $begin;
var_dump($cost);
$begin = getTimeStamp();
for($i = 0 ; $i < 100000 ; $i = $i +1) {
$result = $redis->get($key);
}
$cost = getTimeStamp() - $begin;
var_dump($cost);
$redis->close();

extension= apc.so apc.enabled=1 apc.shm_segments=1 apc.shm_size=64M ; apc内存的大小,最后的大小需要乘上segments的数量,所以这里一共为apc分配64M apc.ttl=7200 apc.user_ttl=7200 apc.enable_cli=1 ; 这个如果不开启,则只可以在网页上进行apc操作,不能通过cli进行apc操作
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了php apc缓存以及与redis的对比,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。