Credis_Client::auth PHP Method

auth() public method

public auth ( string $password ) : boolean
$password string
return boolean
    public function auth($password)
    {
        $response = $this->__call('auth', array($password));
        $this->authPassword = $password;
        return $response;
    }

Usage Example

 public function __construct()
 {
     $this->_timeStart = microtime(true);
     $host = (string) (Mage::getConfig()->getNode(self::XML_PATH_HOST) ?: '127.0.0.1');
     $port = (int) (Mage::getConfig()->getNode(self::XML_PATH_PORT) ?: '6379');
     $pass = (string) (Mage::getConfig()->getNode(self::XML_PATH_PASS) ?: '');
     $timeout = (double) (Mage::getConfig()->getNode(self::XML_PATH_TIMEOUT) ?: self::DEFAULT_TIMEOUT);
     $persistent = (string) (Mage::getConfig()->getNode(self::XML_PATH_PERSISTENT) ?: '');
     $this->_dbNum = (int) (Mage::getConfig()->getNode(self::XML_PATH_DB) ?: 0);
     $this->_compressionThreshold = (int) (Mage::getConfig()->getNode(self::XML_PATH_COMPRESSION_THRESHOLD) ?: self::DEFAULT_COMPRESSION_THRESHOLD);
     $this->_compressionLib = (string) (Mage::getConfig()->getNode(self::XML_PATH_COMPRESSION_LIB) ?: self::DEFAULT_COMPRESSION_LIB);
     $this->_logLevel = (int) (Mage::getConfig()->getNode(self::XML_PATH_LOG_LEVEL) ?: self::DEFAULT_LOG_LEVEL);
     $this->_maxConcurrency = (int) (Mage::getConfig()->getNode(self::XML_PATH_MAX_CONCURRENCY) ?: self::DEFAULT_MAX_CONCURRENCY);
     $this->_breakAfter = (int) (Mage::getConfig()->getNode(sprintf(self::XML_PATH_BREAK_AFTER, session_name())) ?: self::DEFAULT_BREAK_AFTER);
     $this->_botLifetime = (int) (Mage::getConfig()->getNode(self::XML_PATH_BOT_LIFETIME) ?: self::DEFAULT_BOT_LIFETIME);
     if ($this->_botLifetime) {
         $userAgent = empty($_SERVER['HTTP_USER_AGENT']) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
         $this->_isBot = !$userAgent || preg_match(self::BOT_REGEX, $userAgent);
     }
     $this->_redis = new Credis_Client($host, $port, $timeout, $persistent);
     if (!empty($pass)) {
         $this->_redis->auth($pass) or Zend_Cache::throwException('Unable to authenticate with the redis server.');
     }
     $this->_redis->setCloseOnDestruct(FALSE);
     // Destructor order cannot be predicted
     $this->_useRedis = TRUE;
     if ($this->_logLevel >= 7) {
         Mage::log(sprintf("%s: %s initialized for connection to %s:%s after %.5f seconds", $this->_getPid(), get_class($this), $host, $port, microtime(true) - $this->_timeStart), Zend_Log::DEBUG, self::LOG_FILE);
         if ($this->_isBot) {
             Mage::log(sprintf("%s: Bot detected for user agent: %s", $this->_getPid(), $userAgent), Zend_Log::DEBUG, self::LOG_FILE);
         }
     }
 }
All Usage Examples Of Credis_Client::auth