I can not get an improvement in the return of database values using cache, read all documentation (https://docs.phalcon.io/en/latest/reference/models-cache.html), however, still did not get success.
I started the service in the container (DI) this way:
$container->set('modelsCache', function() {
$front = new Phalcon\Cache\Frontend\Data(array('lifetime' => 86400));
$memcached = array('host' => '127.0.0.1', 'port' => '11211');
return (new Phalcon\Cache\Backend\Memcache($front, $memcached));
});
Also, the cache was created in the controller action:
$cache = array('key' => 'my-cache', 'lifetime' => 300);
$conditions = array('cache' => $cache);
$this->view->topics = Topics::find($conditions);
Then I consulted in many ways, including how below:
$this->view->topics = $this->modelsCache->get('my-cache');
But in any way I could get better performance than a normal query to the database.
Am I doing something wrong! Anyone who can help, I would be grateful!