/**
  * return query in cache
  *
  * @param Query   $query
  * @param integer $time
  * @param string  $MODE	    [MODE_GET, MODE_PUT , MODE_NORMAL , MODE_REFRESH]	
  * @param boolean $setCacheable
  * @param string  $namespace
  * @param string  $input_hash
  * 
  * @return Query
  * @access public
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public function cacheQuery(Query $query, $time = 3600, $MODE = 3, $setCacheable = true, $namespace = '', $input_hash = '')
 {
     if (!$query) {
         throw new \Gedmo\Exception\InvalidArgumentException('Invalide query instance');
     }
     // create single file from all input
     if (empty($input_hash)) {
         $input_hash = $namespace . sha1(serialize($query->getParameters()) . $query->getSQL());
     }
     $query->useResultCache(true, $time, (string) $input_hash);
     $query->useQueryCache(true);
     if (method_exists($query, 'setCacheMode')) {
         $query->setCacheMode($MODE);
     }
     if (method_exists($query, 'setCacheable')) {
         $query->setCacheable($setCacheable);
     }
     return $query;
 }