Исправлено поведение при обновлении устаревшего токена

Обновлена логика в компонентах для работы с ключами redis
This commit is contained in:
ErickSkrauch
2016-11-29 01:57:58 +03:00
parent 1e94cda399
commit 5f07834f45
8 changed files with 83 additions and 51 deletions

View File

@@ -3,41 +3,37 @@ namespace common\components\Redis;
use ArrayIterator;
use IteratorAggregate;
use Yii;
class Set extends Key implements IteratorAggregate {
/**
* @return Connection
*/
public static function getDb() {
return Yii::$app->redis;
}
public function add($value) {
static::getDb()->sadd($this->key, $value);
$this->getRedis()->sadd($this->key, $value);
return $this;
}
public function remove($value) {
static::getDb()->srem($this->key, $value);
$this->getRedis()->srem($this->key, $value);
return $this;
}
public function members() {
return static::getDb()->smembers($this->key);
return $this->getRedis()->smembers($this->key);
}
public function getValue() {
return $this->members();
}
public function exists($value) {
return (bool)static::getDb()->sismember($this->key, $value);
public function exists(string $value = null) : bool {
if ($value === null) {
return parent::exists();
} else {
return (bool)$this->getRedis()->sismember($this->key, $value);
}
}
public function diff(array $sets) {
return static::getDb()->sdiff([$this->key, implode(' ', $sets)]);
return $this->getRedis()->sdiff([$this->key, implode(' ', $sets)]);
}
/**