Hi,

I'm beginning with Zend_Cache. I would like to ask your help on caching DB relational data in controller and view script.

Easiest in this case is cache the output of your view script, and let the controller check for cache validity.

if($cache->isValid(some id)) {
   show cached version
} else {
  $this->view->assign('stuff', getStuff())
  $contents =   render view template
  $cache->store(some id, $contents)
  show $contents
}

You could implement an action helper for this.

Another solution is use a view helper to cache the contents of the view script and make sure the controller uses a lazy-load for your database contents. This is more complex though, and imho not really preferable.

HTH
Gerard

Reply via email to