mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Implemented PHP-CS-Fixer support
This commit is contained in:
@@ -157,7 +157,7 @@ class Connection extends Component implements ConnectionInterface {
|
||||
/**
|
||||
* @var array List of available redis commands http://redis.io/commands
|
||||
*/
|
||||
const REDIS_COMMANDS = [
|
||||
public const REDIS_COMMANDS = [
|
||||
'BLPOP', // key [key ...] timeout Remove and get the first element in a list, or block until one is available
|
||||
'BRPOP', // key [key ...] timeout Remove and get the last element in a list, or block until one is available
|
||||
'BRPOPLPUSH', // source destination timeout Pop a value from a list, push it to another list and return it; or block until one is available
|
||||
@@ -368,14 +368,6 @@ class Connection extends Component implements ConnectionInterface {
|
||||
*/
|
||||
private $_client;
|
||||
|
||||
public function getConnection() : ClientInterface {
|
||||
if ($this->_client === null) {
|
||||
$this->_client = new Client($this->prepareParams(), $this->options);
|
||||
}
|
||||
|
||||
return $this->_client;
|
||||
}
|
||||
|
||||
public function __call($name, $params) {
|
||||
$redisCommand = mb_strtoupper($name);
|
||||
if (in_array($redisCommand, self::REDIS_COMMANDS)) {
|
||||
@@ -385,6 +377,14 @@ class Connection extends Component implements ConnectionInterface {
|
||||
return parent::__call($name, $params);
|
||||
}
|
||||
|
||||
public function getConnection(): ClientInterface {
|
||||
if ($this->_client === null) {
|
||||
$this->_client = new Client($this->prepareParams(), $this->options);
|
||||
}
|
||||
|
||||
return $this->_client;
|
||||
}
|
||||
|
||||
public function executeCommand(string $name, array $params = []) {
|
||||
return $this->getConnection()->$name(...$params);
|
||||
}
|
||||
|
||||
@@ -30,11 +30,13 @@ class Key {
|
||||
|
||||
public function setValue($value): self {
|
||||
$this->getRedis()->set($this->key, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function delete(): self {
|
||||
$this->getRedis()->del([$this->getKey()]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -44,17 +46,19 @@ class Key {
|
||||
|
||||
public function expire(int $ttl): self {
|
||||
$this->getRedis()->expire($this->key, $ttl);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function expireAt(int $unixTimestamp): self {
|
||||
$this->getRedis()->expireat($this->key, $unixTimestamp);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function buildKey(array $parts): string {
|
||||
$keyParts = [];
|
||||
foreach($parts as $part) {
|
||||
foreach ($parts as $part) {
|
||||
$keyParts[] = str_replace('_', ':', $part);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@ class Set extends Key implements IteratorAggregate {
|
||||
|
||||
public function add($value): self {
|
||||
$this->getRedis()->sadd($this->getKey(), $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function remove($value): self {
|
||||
$this->getRedis()->srem($this->getKey(), $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user