本文整理汇总了PHP中Phalcon\Mvc\View::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP View::cache方法的具体用法?PHP View::cache怎么用?PHP View::cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\View
的用法示例。
在下文中一共展示了View::cache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testViewOptions
public function testViewOptions()
{
$config = array('cache' => array('service' => 'otherCache'));
$date = date("r");
$content = '<html>' . $date . '</html>' . PHP_EOL;
$di = $this->_getDi('otherCache');
$view = new View($config);
$view->setDI($di);
$view->setViewsDir('unit-tests/views/');
$view->setVar("date", $date);
$view->start();
$view->cache(true);
$view->render('test8', 'other');
$view->finish();
$this->assertEquals($view->getContent(), $content);
$view->reset();
sleep(1);
$view->setVar("date", date("r"));
$view->start();
$view->cache(true);
$view->render('test8', 'other');
$view->finish();
$this->assertEquals($view->getContent(), $content);
}
示例2: testViewOptions
public function testViewOptions()
{
$this->specify("Views are not cached properly when passing options to the constructor", function () {
$this->_clearCache();
$config = array('cache' => array('service' => 'otherCache'));
$date = date("r");
$content = '<html>' . $date . '</html>' . PHP_EOL;
$di = $this->_getDi('otherCache');
$view = new View($config);
$view->setDI($di);
$view->setViewsDir(PATH_DATA . 'views' . DIRECTORY_SEPARATOR);
$view->setVar("date", $date);
$view->start();
$view->cache(true);
$view->render('test8', 'other');
$view->finish();
expect($view->getContent())->equals($content);
$view->reset();
sleep(1);
$view->setVar("date", date("r"));
$view->start();
$view->cache(true);
$view->render('test8', 'other');
$view->finish();
expect($view->getContent())->equals($content);
});
}