Monday, January 02, 2012

Doctrine2 ORM add query result cache and delete cache

// add query result cache
$query = $this->createQueryBuilder('i')
              ->where('i.delete = false')
              ->getQuery();
$query->useResultCache(true, 3600, 'allItems');
$items = $query->getArrayResult();

// delete cache
$em->getConfiguration()
   ->getResultCacheImpl()->delete('allItems');

No comments: