2010年1月16日星期六

Re: [fw-mvc] Re: [fw-general] Bootstrap Resource usage in model - best practice advice please

> Then the cache instance probably should be a singleton.

Don't think so. Singleton only if you have base model class, and/or only for default cache (BaseModel::setDefaultCache(), BaseModel::getDefaultCache()). Otherwise singleton is wrong approach.

--
Regards,
Vladas Diržys


On Fri, Jan 15, 2010 at 19:31, Andreas Möller <localheinz@l8m.de> wrote:
Does this means that you should have base class for all models with
getCache method, and extend it?

Then the cache instance probably should be a singleton.

 protected function _getCache()
 {
   if (self::$_cacheInstance === NULL) {
     // self::$_cacheInstance = Zend_Registry::get('Zend_Cache');
     self::$_cacheInstance = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('Cache');
   }
   return self::$_cacheInstance;
 }


Best regards,

Andreas


没有评论: