Thank you for answering.
I used this:
$di->set('modelsCache', function() {
//Cache data for one day by default
$frontCache = new \Phalcon\Cache\Frontend\Data(array(
"lifetime" => 86400
));
// https://docs.phalcon.io/en/latest/reference/models-cache.html
//Memcached connection settings
// $cache = new \Phalcon\Cache\Backend\Memcache($frontCache, array(
// "host" => "192.168.1.44",
// "port" => "11211"
// ));
// https://docs.phalcon.io/en/latest/reference/cache.html
$cache = new \Phalcon\Cache\Backend\File($frontCache, array(
"cacheDir" => "../app/cache/"
));
return $cache;
});
But it doesn't work.
My function:
public function indexAction()
{
// $this->session->conditions = null;
// $this->session->destroy();
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Nhachung", $_POST);
$this->persistent->searchParams = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
if ($numberPage <= 0) {
$numberPage = 1;
}
}
$parameters = array();
if ($this->persistent->searchParams) {
$parameters = $this->persistent->searchParams;
}
$parameters["cache"] = array('lifetime' => 3600, 'key' => 'my-find-key123saf');
$nhachung = Nhachung::find($parameters);
if (count($nhachung) == 0) {
$this->flash->notice("The search did not find any nhachung");
return $this->forward("nhachung/index");
}
$paginator = new Phalcon\Paginator\Adapter\Model(array(
"data" => $nhachung,
"limit" => 10,
"page" => $numberPage
));
$page = $paginator->getPaginate();
$this->view->setVar("page", $page);
}
Url test: https://localhost/invo/nhachung/index?page=1
if I comment this line:
// $parameters["cache"] = array('lifetime' => 3600, 'key' => 'my-find-key123saf'); .
Everything works fine.
Chrome does not return anything "No data received". It's really difficult to debug with Phalcon :(.