示例#1
0
 /**
  * Check DB connection
  *
  * @return bool
  */
 public function hasConnection()
 {
     if (!$this->_useRedis) {
         return parent::hasConnection();
     }
     try {
         $this->_redis->connect();
         if ($this->_logLevel >= Zend_Log::DEBUG) {
             $this->_log("Connected to Redis");
         }
         return TRUE;
     } catch (Exception $e) {
         Mage::logException($e);
         $this->_redis = NULL;
         Mage::log('Unable to connect to Redis; falling back to MySQL handler', Zend_Log::EMERG);
         // Fall-back to MySQL handler. If this fails, the file handler will be used.
         $this->_useRedis = FALSE;
         parent::__construct();
         return parent::hasConnection();
     }
 }
 /**
  * Check DB connection
  *
  * @return bool
  */
 public function hasConnection()
 {
     if (!$this->_useRedis) {
         return parent::hasConnection();
     }
     try {
         $this->_redis->connect();
         if ($this->_logLevel >= 7) {
             Mage::log(sprintf("%s: Connected to Redis", $this->_getPid()), Zend_Log::DEBUG, self::LOG_FILE);
             // reset timer
             $this->_timeStart = microtime(true);
         }
         return TRUE;
     } catch (Exception $e) {
         Mage::logException($e);
         $this->_redis = NULL;
         if ($this->_logLevel >= 0) {
             Mage::log(sprintf("%s: Unable to connect to Redis; falling back to MySQL handler", $this->_getPid()), Zend_Log::EMERG, self::LOG_FILE);
         }
         // Fall-back to MySQL handler. If this fails, the file handler will be used.
         $this->_useRedis = FALSE;
         parent::__construct();
         return parent::hasConnection();
     }
 }