http://docs.phalconphp.com/en/0.6.0/reference/di.html
在public / index.php中,编码:
$di->set('viewCache', function(){
//Cache data for one day by default
$frontCache = new Phalcon\Cache\Frontend\Output(array(
"lifetime" => 86400
));
//Memcached connection settings
$cache = new Phalcon\Cache\Backend\File($frontCache, array(
"cacheDir" => "../apps/caches/"
));
return $cache;
});
在控制器中,我可以使用this-> view-> cache(),为什么不在服务名称约定中查看Cache呢?
答案 0 :(得分:0)
可以像这样访问服务viewCache
:
// In controller
$this->view->cache();
或
// In controller
$this->di->get('viewCache');
或
// In a module or other file
$di = \Phalcon\DI::getDefault();
$di->get('viewCache');