/**
  * @param string   $entity
  * @param int      $id
  * @param int|null $ttl
  *
  * @return object|null
  */
 public function find($entity, $id, $ttl = null)
 {
     $query = $this->createQueryBuilder($entity, 'x')->select('x')->where('x.id = :id')->setParameter('id', $id)->getQuery();
     if ($ttl !== false) {
         $key = sprintf($this->cache->getEntityKeyFormat(), $this->cache->getEntityClassKey($entity), $id);
         $query->useResultCache(true, $ttl, $key);
     }
     return $query->getOneOrNullResult();
 }