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__ ) );//设置缓存
}