久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      Asf PHP開發(fā)之配置信息常駐系統(tǒng)內(nèi)存

      傳統(tǒng)MVC 與 Asf 比較

      傳統(tǒng)的MVC框架

      每次請求都會去重新加載配置文件。即使配置文件內(nèi)容沒有更新, 也會去重新加載一次。這是一個很不好的設(shè)計。(開啟Opcache情況下, 還是有執(zhí)行的過程時間)

      Asf框架

      讀取到配置文件的內(nèi)容保存到系統(tǒng)內(nèi)存, 下一次請求直接去內(nèi)存讀取數(shù)據(jù)。Asf 也提供非常簡單的配置實現(xiàn) Config Cache。

      什么場景下開啟Config Cache合適?

      ● 建議在Web應(yīng)用場景下都開啟吧, 后面版本可能會默認啟用

      ● 在CLI、多線程模式下開啟同樣生效, 只是PHP腳本每次執(zhí)行完就釋放了

      ● 支持數(shù)據(jù)類型有: strings, arrays, integers, boolean, doubles, floats, null

      流程圖

      Asf PHP開發(fā)之配置信息常駐系統(tǒng)內(nèi)存

      開啟緩存方法

      <?php ini_set('asf.cache_config_enable', 1); /* 開啟配置文件緩存 */ ini_set('asf.cache_config_expire', 300); /* 設(shè)置緩存多少秒之后過期, 300 seconds by default */

      框架入口方式加載php/ini配置文件

      <?php define('APP_PATH', dirname(__DIR__)); /* 緩存 config.ini 文件 */ $app = new AsfApplication(APP_PATH . '/config/config.ini'); $app->run();

      AsfConfigPhp 加載php配置文件

      <?php $conf_php =  new AsfConfigPhp(CONFIG_PATH . '/config.db.php');

      AsfConfigIni 加載ini配置文件

      <?php $conf_ini =  new AsfConfigIni(CONFIG_PATH . '/config.redis.ini');

      讀取配置內(nèi)容方法

      <?php print_r(AsfApplication::getInstance()->getConfig()->toArray()); print_r(AsfConfig::get()->toArray());

      性能測試

      ● 在開啟 Opcache 情況下, 簡單做了一個 Config Cache 性能測試, ab -c100 -n10000

      ● 配置文件中配置項復(fù)雜程度與性能指標是有直線聯(lián)系的喲

      開啟緩存 asf.cache_config_enable = 1

      Total transferred:      16109994 bytes HTML transferred:       14259994 bytes Requests per second:    6859.01 [#/sec] (mean) Time per request:       14.579 [ms] (mean) Time per request:       0.146 [ms] (mean, across all concurrent requests)

      無緩存

      Total transferred:      16080000 bytes HTML transferred:       14230000 bytes Requests per second:    6398.22 [#/sec] (mean) Time per request:       15.629 [ms] (mean) Time per request:       0.156 [ms] (mean, across all concurrent requests)

      提示

      Cache Config 不是基于共享內(nèi)存的, 是基于 PHP 進程的喲, 不會有共享內(nèi)存鎖的問題。

      推薦:《PHP教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號