Hi, i think redis is far the best
exmaple service
:
use \Phalcon\Cache\Backend\Redis;
$this->di->set('modelsCache', function(){
$frontCache = new FrontendData(
array(
"lifetime" => 186400
)
);
$cache = new Redis($frontCache, array(
'host' => '127.0.0.1',
'port' => 6379,
"statsKey" => '_PHCM'
));
if (APPLICATION_ENV === 'development'){
$cache->flush();
}
return $cache;
}, true);
example model find cache:
$products = Products::find(
array(
"cache" => array(
"key" => "my-cache", //each duifferent query has to have itts own key
"lifetime" => 300
)
)
);
part of a view
$frontCache = new \Phalcon\Cache\Frontend\Output(array(
"lifetime" => 172800 //2 days
));
$cache = new \Phalcon\Cache\Backend\Redis($frontCache, array(
'host' => '127.0.0.1',
'port' => 6379,
"statsKey" => '_PHCM'
));
$content = $cache->start('main_rotation');
if ($content === null) {
//ECHO BLA BLA BLA
} else {
echo $content;
}
there is a whole page cahckign with key in phalcon/docs repo you can check it out.
All things that I posted exists in the docs aswell.
Have fun