Doctrine 1
  1. Doctrine 1
  2. DC-559

Doctrine_Core::loadModels() caching

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: 1.2.2
    • Component/s: None
    • Labels:
      None

      Description

      Add ability to cache result of Doctrine_Core::loadModels().
      My "models" folder contains more than 20 record classes plus more than 20 base classes. I added result caching for conservative model loading and it's reduced application bootstrap time more than 100ms.
      Here code that I added to Doctrine_Core::loadModels()
      Cache hit check at the beginning of the method

                      $models = zend_shm_cache_fetch('doctrine::models_conservative');
                      $modelPatch = zend_shm_cache_fetch('doctrine::models_conservative_paths');
                      if(false !== $models && false !== $modelPatch){
                          self::$_loadedModelFiles = $modelPatch;
                          return $models;
                      }
      

      Result caching before return data

                 asort($loadedModels);
                  zend_shm_cache_store('doctrine::models_conservative',$loadedModels);
                  zend_shm_cache_store('doctrine::models_conservative_paths',self::$_loadedModelFiles);
                  return $loadedModels;
      

      Of course zend_shm_cache_* is not proposed as caching solution.
      I didn't use agressive model loading, but I think that caching for aggresive modlel loading can be done with compilation of all models to one file

        Activity

        Hide
        Jonathan H. Wage added a comment -

        The changes are not valid and you can do the same thing outside of Doctrine in your bootstrap. We don't need to patch Doctrine in order for you to do this.

        Show
        Jonathan H. Wage added a comment - The changes are not valid and you can do the same thing outside of Doctrine in your bootstrap. We don't need to patch Doctrine in order for you to do this.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Lozovoy Max
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: