<output id="r87xx"></output>
    1. 
      
      <mark id="r87xx"><thead id="r87xx"><input id="r87xx"></input></thead></mark>
        •   

               當前位置:首頁>軟件介紹>使用 eAccelerator加速PHP代碼的目的 查詢:
               
          使用 eAccelerator加速PHP代碼的目的

                  使用 eAccelerator加速PHP代碼的目的使用 eAccelerator加速PHP代碼 eAccelerator 真是一個好東西(它的前身是truck-mmcache)。

                  簡單來講它是一套配合PHP(支持PHP5)運作的緩存系統(tǒng),通過共享內(nèi)存或磁盤文件方式交換數(shù)據(jù)。

                  它被廣為使用的是PHP源碼“編碼”(不太貼切的稱為“加密”)和緩存PHP執(zhí)行的中間碼以加速。關(guān)于 eA 的安裝使用的文章已經(jīng)很多而且也很詳細了,

                  這次我想推薦的是用它輔助程序設(shè)計緩存,它提供了一組API如下:

                  是一個非常便捷而又穩(wěn)定的本機緩存實現(xiàn)方式,目前這部分設(shè)計似乎只支持于共享內(nèi)存,所以只能用于 Unix -Like OS 了,windows的就沒這個福氣了。

                  1. eaccelerator_put($key, $value, $ttl=0)

                  以 $key 為鍵名存進緩存(php4下支持對像類型,看源碼好像 將 $value

                  zend2里不支持了),$ttl 是這個緩存的生命周期,單位是秒,省略該參數(shù)或

                  指定為 0 表示不限時,直到服務器重啟清空為止。

                  2. eaccelerator_get($key)

                  根據(jù) $key 從緩存中返回相應的 eaccelerator_put() 存進去的數(shù)據(jù),如果這項緩存已經(jīng)過期或不存在那么返回值是 NULL

                  3. eaccelerator_rm($key)

                  根據(jù) $key 移除緩存

                  4. eaccelerator_gc()

                  移除清理所有已過期的 key

                  5. eaccelerator_lock($key)

                  為 $key 加上鎖定操作,以保證多進程多線程操作時數(shù)據(jù)的同步。需要調(diào)用 eaccelerator_unlock($key) 來釋放這個鎖或等待程序請求結(jié)束時自動釋放這個鎖。

                  例如:

                  <?php

                  eaccelerator_lock("count");

                  eaccelerator_put("count",eaccelerator_get("count")+1));

                  ?>

                  6. eaccelerator_unlock($key)

                  根據(jù) $key 釋放鎖

                  7. eaccelerator_cache_output($key, $eval_code, $ttl=0)

                  將 $eval_code 代碼的輸出緩存 $ttl 秒,($ttl參數(shù)

                  同 eacclerator_put)

                  For Example:

                  <?php

                  eaccelerator_cache_output('test', 'echo time(); phpinfo();', 30);

                  ?>

                  8. eaccelerator_cache_result($key, $eval_code, $ttl=0)

                  將 $eval_code 代碼的執(zhí)行結(jié)果緩存 $ttl 秒,($ttl參數(shù)

                  同 eacclerator_put),類似 cache_output

                  For Example:

                  <?php

                  eaccelerator_cache_result('test', ' time() . "Hello";', 30);

                  ?>

                  9. eaccelerator_cache_page($key, $ttl=0)

                  將當前整頁緩存 $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() 執(zhí)行的緩存,參數(shù)也是 $key

                  ______________________________________________

                  (作個簡單例子看看它的威力,注意在 cli 模式下可能無效~)

                  <?php

                  class test_cache {

                  var $pro = 'hello';

                  function test_cache() {

                  echo "Object Created! br

                  }

                  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

                  }

                  else {

                  echo "cached br

                  }

                  echo $tt-

                  $tt- func();

                  $tt- now(time() + 86400);

                  ?>  

                  


          PHP陽歷轉(zhuǎn)農(nóng)歷的類PHP模板引擎smarty進門
          PHP中多態(tài)如何實現(xiàn)PHP執(zhí)行系統(tǒng)外部命令
          通過 PDO 將 PHP 連接到 DB2 和 Cloudscapephp多進程編程實例
          PHP高效率寫法OOP的PHP長啥樣
          絕對簡單易學的PHP入門教程自己寫的php模板引擎
          優(yōu)化php提高性能的一些方法頁面顯示PHP源碼
          系統(tǒng)管理員必須知道的PHP安全實踐五種常見的PHP設(shè)計模式
          微信公眾平臺開發(fā)方案書通過PHP操作SQLServer數(shù)據(jù)庫
          信息發(fā)布:廣州名易軟件有限公司 http://www.jetlc.com
          • 勁爆價:
            不限功能
            不限用戶
            1998元/年

          • 微信客服

            <output id="r87xx"></output>
          1. 
            
            <mark id="r87xx"><thead id="r87xx"><input id="r87xx"></input></thead></mark>
              • 久久九九热re6这里有精品 | www.日逼网站 | 親子亂子倫XXXX0路舒淇 日本丰满少妇黄大片在线观看 | 最新中文字幕免费MV第一季歌词 | 狠狠操综合网 | 美女尻屄视频 | 在线观看色情视频 | 欧美精产国品一区二区区别 | 精品第1页 | www.俺来也.com |