使用 eAccelerator加速PHP代码的方法

2019-04-11 00:48:22于海丽

  将当前整页缓存 $ttl 秒。 
  For Example: 
  <?php 
    eaccelerator_cache_page($_SERVER['PHP_SELF'].'?GET='.serialize($_GET),30); 
    echo time(); 
    phpinfo(); 
  ?> 

10. eaccelerator_rm_page($key) 
  删除由  eaccelerator_cache_page() 执行的缓存,参数也是 $key 

______________________________________________ 
(作个简单例子看看它的威力,注意在 cli 模式下可能无效!) 


<?phpclass test_cache {  var $pro = 'hello';  function test_cache() {    echo "Object Created!<br>/n";  }  function func() {    echo ', the world!';  }  function now($t) {    echo date('Y-m-d H:i:s', $t);  }}$tt = eaccelerator_get("test_tt");if (!$tt){  $tt = new test_cache;  eaccelerator_put("test_tt", $tt);  echo "no cached!<br>/n";}else {  echo "cached<br>/n";}echo $tt->pro; $tt->func();$tt->now(time() + 86400);?>
相关文章 大家在看