Skip to content

Commit

Permalink
fix: swoft-cloud/swoft/issues/1312 redis not support select command
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jul 2, 2020
1 parent 57e9a0f commit 7f08af4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/redis/src/Connection/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Swoft\Stdlib\Helper\PhpHelper;
use Throwable;
use function count;
use function method_exists;
use function sprintf;

/**
Expand Down Expand Up @@ -315,7 +316,7 @@ abstract class Connection extends AbstractConnection implements ConnectionInterf
* @param Pool $pool
* @param RedisDb $redisDb
*/
public function initialize(Pool $pool, RedisDb $redisDb)
public function initialize(Pool $pool, RedisDb $redisDb): void
{
$this->pool = $pool;
$this->redisDb = $redisDb;
Expand Down Expand Up @@ -391,10 +392,10 @@ public function command(string $method, array $parameters = [], bool $reconnect
{
try {
$lowerMethod = strtolower($method);
if (!in_array($lowerMethod, $this->supportedMethods, true)) {
throw new RedisException(
sprintf('Method(%s) is not supported!', $method)
);
// if (!in_array($lowerMethod, $this->supportedMethods, true)) {
// Up: use method_exists check command is valid.
if (!method_exists($this->client, $lowerMethod)) {
throw new RedisException(sprintf('Redis method(%s) is not supported!', $method));
}

// Before event
Expand Down
2 changes: 1 addition & 1 deletion src/redis/src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
* @method static array xRange(string $stream_key, string $start, string $end, int $count)
* @method static array xRevRange(string $stream_key, string $end, string $start, int $count)
* @method static array xRead(array|string $stream_keys, int $count, int $block)
* @method static array xReadGroup(string $group, string consumer, array|string $stream_keys, int $count, int $block)
* @method static array xReadGroup(string $group, string $consumer, array|string $stream_keys, int $count, int $block)
* @method static integer xTrim(string $stream_key, int $max_len, bool $approximate)
*/
class Redis
Expand Down
2 changes: 1 addition & 1 deletion src/redis/src/RedisDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function getConnection(): Connection
$connection = $connections[$this->driver] ?? null;

if (!$connection instanceof Connection) {
throw new RedisException(sprintf('Connection(dirver=%s) is not exist', $this->driver));
throw new RedisException(sprintf('Connection(driver=%s) is not exist', $this->driver));
}

return $connection;
Expand Down

0 comments on commit 7f08af4

Please sign in to comment.