mirror of
https://github.com/elyby/accounts.git
synced 2025-03-02 06:32:47 +05:30
Reworked oauth_sessions table. Added extension to use MariaDB's JSON columns. Rewritten tests for authorization_code grant for client side. Deprecate some old shit. [skip ci]
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
namespace common\components\Redis;
|
|
|
|
use ArrayIterator;
|
|
use IteratorAggregate;
|
|
use Yii;
|
|
|
|
/**
|
|
* @deprecated
|
|
*/
|
|
class Set extends Key implements IteratorAggregate {
|
|
|
|
public function add($value): self {
|
|
Yii::$app->redis->sadd($this->getKey(), $value);
|
|
return $this;
|
|
}
|
|
|
|
public function remove($value): self {
|
|
Yii::$app->redis->srem($this->getKey(), $value);
|
|
return $this;
|
|
}
|
|
|
|
public function members(): array {
|
|
return Yii::$app->redis->smembers($this->getKey());
|
|
}
|
|
|
|
public function getValue(): array {
|
|
return $this->members();
|
|
}
|
|
|
|
public function exists(string $value = null): bool {
|
|
if ($value === null) {
|
|
return parent::exists();
|
|
}
|
|
|
|
return (bool)Yii::$app->redis->sismember($this->getKey(), $value);
|
|
}
|
|
|
|
public function diff(array $sets): array {
|
|
return Yii::$app->redis->sdiff([$this->getKey(), implode(' ', $sets)]);
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function getIterator() {
|
|
return new ArrayIterator($this->members());
|
|
}
|
|
|
|
}
|