yii 的常見加速方式_PHP教程

來源:互聯網
上載者:User
1、開啟APC ,緩衝yiilite.php 檔案

關於開啟APC來說,yii雖然本身可以按照需求來載入所需檔案,但其實每次去判斷什麼該載入什麼不該還是需要花掉不少時間,既然是常用的,不如常駐記憶體來的方便。

How to:

修改index.php 檔案,將引用的yii.php 改成yiilite.php (YiiFramework 裡都有這個檔案)。

其次,安裝php_apc擴充 我的系統是ubuntu,所以比較方便,直接apt-get install php_apc 即可,安裝完畢後,他會在/etc/php5/apache2/conf.d 中有個啟動項檔案,直接重啟apache 即可生效(apachectl restart 或者service apache2 restart)

另外apc 源碼裡有個pac.php 檔案可以查看pac在系統中啟動並執行狀況,當然你不查看實際上沒有任何影響

2、關閉debug 選項

index.php 的debug 記得關閉。

3、緩衝ActiveRecord 的常規載入。

在使用ActiveRecord 的時候,它會載入很多常規資訊,在表結構不發生變化的時候,這些資訊是不會變的,所以,緩衝起來 方法是在配置的地方多一個欄位schemaCachingDuration

'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=XXX',
'emulatePrepare' => true,
'schemaCachingDuration'=>'3600',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
),

4、大規模資料庫操作的時候,請用DAO。。。。。

暫時就這麼多。

http://www.bkjia.com/PHPjc/440318.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/440318.htmlTechArticle1、開啟APC ,緩衝yiilite.php 檔案 關於開啟APC來說,yii雖然本身可以按照需求來載入所需檔案,但其實每次去判斷什麼該載入什麼不該還是需...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.