phalcon官方站点上的视图缓存用法根本就是不通的
现提供一种行的通的方法例如以下:
public function testAction() { if( $this->view->getCache()->exists( __CLASS__ . __FUNCTION__ ) )//检查缓存是否存在 { return $this->response->setContent( $this->view->getCache()->get( __CLASS__ . __FUNCTION__ )); //取缓存 } $iSum = 0; for( $i = 1; $i < 65536; ++$i ) { $iSum += $i; } $this->view->setVar( 'sum', $iSum ); $this->view->cache( array( 'lifetime' => 240, 'key' => __CLASS__ . __FUNCTION__ ) );//设置缓存 }