Tao

          Tao obeys its own inherent Nature

          How To: Clear cache for symfony

          Original article: http://www.symfony-project.com/book/1_0/18-Performance

          Clearing Selective Parts of the Cache

          During application development, you have to clear the cache in various situations:

          • When you create a new class: Adding a class to an autoloading directory (one of the project's lib/ folders) is not enough to have symfony find it automatically. You must clear the autoloading configuration cache so that symfony browses again all the directories of the autoload.yml file and references the location of autoloadable classes--including the new ones.
          • When you change the configuration in production: The configuration is parsed only during the first request in production. Further requests use the cached version instead. So a change in the configuration in the production environment (or any environment where SF_DEBUG is turned off) doesn't take effect until you clear the cached version of the file.
          • When you modify a template in an environment where the template cache is enabled: The valid cached templates are always used instead of existing templates in production, so a template change is ignored until the template cache is cleared or outdated.
          • When you update an application with the sync command: This case usually covers the three previous modifications.

          The problem with clearing the whole cache is that the next request will take quite long to process, because the configuration cache needs to be regenerated. Besides, the templates that were not modified will be cleared from the cache as well, losing the benefit of previous requests.

          That means it's a good idea to clear only the cache files that really need to be regenerated. Use the options of the clear-cache task to define a subset of cache files to clear, as demonstrated in Listing 18-14.

          Listing 18-14 - Clearing Only Selective Parts of the Cache

          // Clear only the cache of the myapp application
          > symfony clear-cache myapp

          // Clear only the HTML cache of the myapp application
          > symfony clear-cache myapp template

          // Clear only the configuration cache of the myapp application
          > symfony clear-cache myapp config

          You can also remove files by hand in the cache/ directory, or clear template cache files selectively from the action with the $cacheManager->remove() method, as described inChapter 12

           

          Note:

          1. We can use $cacheManager->remove() to clear cache after we deployed a new version product.

          2. write code to generate models from database, and then call $cacheManager->remove() to clear cache.


           

          posted on 2007-11-13 17:23 wade 閱讀(629) 評(píng)論(0)  編輯  收藏 所屬分類: PHPSymfony


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          <2007年11月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          統(tǒng)計(jì)

          常用鏈接

          留言簿(7)

          隨筆分類

          隨筆檔案

          相冊(cè)

          Photo

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 万载县| 克山县| 河北省| 台江县| 浦县| 淳安县| 循化| 无为县| 亚东县| 兴和县| 新巴尔虎右旗| 兴安盟| 依兰县| 安新县| 成安县| 南开区| 伊吾县| 桂阳县| 麻城市| 锡林浩特市| 象山县| 乌鲁木齐县| 景东| 永城市| 石河子市| 双柏县| 敦化市| 嘉义县| 威海市| 东乡族自治县| 霍城县| 密山市| 四会市| 左云县| 连云港市| 驻马店市| 内丘县| 闻喜县| 临城县| 德惠市| 乌拉特前旗|