Beispiel #1
0
 /**
  * @param array $tags
  */
 protected function _removeByMatchingAnyTags($tags)
 {
     if ($this->_useLua) {
         $scriptSha1 = $this->_notMatchingTags ? self::LUA_CLEAN_NMT_SH1 : self::LUA_CLEAN_SH1;
         $pTags = $this->_preprocessTagIds($tags);
         $sArgs = array(self::PREFIX_KEY, self::SET_TAGS, self::SET_IDS);
         if (!$this->_redis->evalSha($scriptSha1, $pTags, $sArgs)) {
             $script = "local keysToDel = redis.call('SUNION', unpack(KEYS)) " . "for _, keyname in ipairs(keysToDel) do " . "redis.call('DEL', ARGV[1]..keyname) " . ($this->_notMatchingTags ? "redis.call('SREM', ARGV[3], keyname) " : "") . "end " . "redis.call('DEL', unpack(KEYS)) " . "redis.call('SREM', ARGV[2], unpack(KEYS)) " . "return true";
             $this->_redis->eval($script, $pTags, $sArgs);
         }
         return;
     }
     $ids = $this->getIdsMatchingAnyTags($tags);
     $this->_redis->pipeline()->multi();
     if ($ids) {
         // Remove data
         $this->_redis->del($this->_preprocessIds($ids));
         // Remove ids from list of all ids
         if ($this->_notMatchingTags) {
             $this->_redis->sRem(self::SET_IDS, $ids);
         }
     }
     // Remove tag id lists
     $this->_redis->del($this->_preprocessTagIds($tags));
     // Remove tags from list of tags
     $this->_redis->sRem(self::SET_TAGS, $tags);
     $this->_redis->exec();
 }
 /**
  * Destroy session
  *
  * @param string $sessionId
  * @return boolean
  */
 public function destroy($sessionId)
 {
     if (!$this->_useRedis) {
         return parent::destroy($sessionId);
     }
     if ($this->_logLevel >= 7) {
         Mage::log(sprintf("%s: Destroying ID %s", $this->_getPid(), $sessionId), Zend_Log::DEBUG, self::LOG_FILE);
     }
     $this->_redis->pipeline();
     if ($this->_dbNum) {
         $this->_redis->select($this->_dbNum);
     }
     $this->_redis->del(self::SESSION_PREFIX . $sessionId);
     $this->_redis->exec();
     return TRUE;
 }
Beispiel #3
0
 /**
  * Log a hit or a miss to Redis.
  *
  * @param string $fullActionName
  * @param bool $hit
  */
 public function logRequest($fullActionName, $hit)
 {
     try {
         $redis = new Credis_Client($this->config->server, NULL, 0.1);
         $redis->pipeline();
         if ($this->config->db) {
             $redis->select($this->config->db);
         }
         $redis->incr('diehard:' . ($hit ? 'hit' : 'miss'));
         if ($fullActionName && $this->config->is('full_action_name')) {
             $redis->incr('diehard:' . $fullActionName . ':' . ($hit ? 'hit' : 'miss'));
         }
         $redis->exec();
         $redis->close();
     } catch (Exception $e) {
         Mage::log($e->getMessage(), Zend_Log::ERR, 'diehard_counter.log');
     }
 }
 /**
  * @param array $tags
  */
 protected function _removeByMatchingAnyTags($tags)
 {
     $ids = $this->getIdsMatchingAnyTags($tags);
     $this->_redis->pipeline()->multi();
     if ($ids) {
         // Remove data
         $this->_redis->del($this->_preprocessIds($ids));
         // Remove ids from list of all ids
         if ($this->_notMatchingTags) {
             $this->_redis->sRem(self::SET_IDS, $ids);
         }
     }
     // Remove tag id lists
     $this->_redis->del($this->_preprocessTagIds($tags));
     // Remove tags from list of tags
     $this->_redis->sRem(self::SET_TAGS, $tags);
     $this->_redis->exec();
 }
Beispiel #5
0
 /**
  * Destroy session
  *
  * @param string $sessionId
  * @return boolean
  */
 public function destroy($sessionId)
 {
     $this->profilerStart(__METHOD__);
     if ($this->_logLevel >= \Zend_Log::DEBUG) {
         $this->_log(sprintf("Destroying ID %s", $sessionId));
     }
     $this->_redis->pipeline();
     if ($this->_dbNum) {
         $this->_redis->select($this->_dbNum);
     }
     $this->_redis->del(self::SESSION_PREFIX . $sessionId);
     $this->_redis->exec();
     $this->profilerStop(__METHOD__);
     return TRUE;
 }
Beispiel #6
0
 /**
  * Destroy session
  *
  * @param string $sessionId
  * @return boolean
  */
 public function destroy($sessionId)
 {
     if (!$this->_useRedis) {
         return parent::destroy($sessionId);
     }
     Varien_Profiler::start(__METHOD__);
     if ($this->_logLevel >= Zend_Log::DEBUG) {
         $this->_log(sprintf("Destroying ID %s", $sessionId));
     }
     $this->_redis->pipeline();
     if ($this->_dbNum) {
         $this->_redis->select($this->_dbNum);
     }
     $this->_redis->del(self::SESSION_PREFIX . $sessionId);
     $this->_redis->exec();
     Varien_Profiler::stop(__METHOD__);
     return TRUE;
 }
Beispiel #7
0
 /**
  * Destroy session
  *
  * @param string $sessionId
  * @return boolean
  */
 public function destroy($sessionId)
 {
     $this->_log(sprintf("Destroying ID %s", $sessionId));
     $this->_redis->pipeline();
     if ($this->_dbNum) {
         $this->_redis->select($this->_dbNum);
     }
     $this->_redis->del(self::SESSION_PREFIX . $sessionId);
     $this->_redis->exec();
     return true;
 }