コード例 #1
0
ファイル: QueueManager.php プロジェクト: bazo/qu
 /**
  * @param string $queue
  * @return QueueManager
  */
 public function clearQueue($queue)
 {
     $this->redis->multi();
     $this->redis->sRem(self::QUEUE_KEY, $queue);
     $this->redis->lTrim($this->formatQueueKey($queue), 1, 0);
     $this->redis->exec();
     return $this;
 }
コード例 #2
0
 /**
  * @return bool
  */
 public function close()
 {
     foreach ($this->ssIds as $key => $yes) {
         $this->client->unlock($key);
     }
     $this->ssIds = array();
     return TRUE;
 }
コード例 #3
0
ファイル: RedisStorage.php プロジェクト: kdyby/redis
 /**
  * @param array $keys
  * @return array
  */
 private function doMultiRead(array $keys)
 {
     $formatedKeys = array_map([$this, 'formatEntryKey'], $keys);
     $result = [];
     foreach ($this->client->send('mget', [$formatedKeys]) as $index => $stored) {
         $key = $keys[$index];
         $result[$key] = $stored !== FALSE ? self::processStoredValue($key, $stored) : NULL;
     }
     return $result;
 }
コード例 #4
0
ファイル: RedisSessionHandler.php プロジェクト: kdyby/redis
 /**
  * @param string $id
  * @return string
  */
 protected function lock($id)
 {
     try {
         $key = $this->formatKey($id);
         $this->client->lock($key);
         $this->ssIds[$id] = $key;
         return $key;
     } catch (LockException $e) {
         throw new SessionHandlerException(sprintf('Cannot work with non-locked session id %s: %s', $id, $e->getMessage()), 0, $e);
     }
 }
コード例 #5
0
ファイル: ExclusiveLock.php プロジェクト: JanPetr/Redis
 /**
  * @param string $key
  * @throws LockException
  */
 public function increaseLockTimeout($key)
 {
     if (!isset($this->keys[$key])) {
         return FALSE;
     }
     if ($this->keys[$key] <= time()) {
         throw LockException::durabilityTimedOut();
     }
     $oldTimeout = $this->client->getSet($this->formatLock($key), $timeout = $this->calculateTimeout());
     if ((int) $oldTimeout !== (int) $this->keys[$key]) {
         throw LockException::invalidDuration();
     }
     $this->keys[$key] = $timeout;
     return TRUE;
 }
コード例 #6
0
 /**
  * @param string $key
  * @throws LockException
  */
 public function increaseLockTimeout($key)
 {
     if (!isset($this->keys[$key])) {
         return FALSE;
     }
     if ($this->keys[$key] <= time()) {
         throw new LockException("Process ran too long. Increase lock duration, or extend lock regularly.");
     }
     $oldTimeout = $this->client->getSet($this->formatLock($key), $timeout = $this->calculateTimeout());
     if ((int) $oldTimeout !== (int) $this->keys[$key]) {
         throw new LockException("Some rude client have messed up the lock duration.");
     }
     $this->keys[$key] = $timeout;
     return TRUE;
 }
コード例 #7
0
ファイル: RedisJournal.php プロジェクト: kdyby/redis
 /**
  * @param string $tag
  *
  * @return array
  */
 private function tagEntries($tag)
 {
     return $this->client->sMembers($this->formatKey($tag, self::KEYS)) ?: [];
 }
コード例 #8
0
 /**
  * Verify, that redis is installed, working and has the right version.
  */
 public function beforeCompile()
 {
     $config = $this->getConfig($this->defaults);
     if ($config['versionCheck'] && ($config['journal'] || $config['storage'] || $config['session'])) {
         $client = new RedisClient($config['host'], $config['port'], $config['database'], $config['timeout'], $config['auth']);
         $client->assertVersion();
         $client->close();
     }
 }
コード例 #9
0
ファイル: RedisExtension.php プロジェクト: kdyby/redis
 /**
  * Verify, that redis is installed, working and has the right version.
  */
 public function beforeCompile()
 {
     foreach ($this->configuredClients as $config) {
         if (!$config['versionCheck']) {
             continue;
         }
         $client = new RedisClient($config['host'], $config['port'], $config['database'], $config['timeout'], $config['auth']);
         $client->assertVersion();
         $client->close();
     }
 }