I have the following action in my controller :
public function popularPlacesAction()
{
$em = $this->getDoctrine()->getManager();
$query = $em->createQuery(
"SELECT COUNT(s.id) as total, l.city as name, l.country_code as country_code
FROM AcmeMyBundle:Sample s
LEFT JOIN s.location l
WHERE l.city != ''
GROUP BY name
ORDER BY total DESC"
)->setMaxResults(15);
$cities = $query->getResult();
return array(
'cities' => $cities
);
}
I want to use cache to set an expiration date for the response, don't matter if the result of the query have changed. I just want to set the response as public and refresh the response every hour for exemple. How to accomplish this without performing the doctrine query when the response come from the cache ?