Skip to content

Commit

Permalink
Merge pull request #29606 from driesvints/redis-5
Browse files Browse the repository at this point in the history
[5.8] Add Redis 5 support
  • Loading branch information
taylorotwell authored Aug 16, 2019
2 parents e78af62 + a8acab1 commit 66b3188
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
before_install:
- phpenv config-rm xdebug.ini || true
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- printf "\n" | pecl install -f redis-4.3.0
- printf "\n" | pecl install -f redis
- travis_retry composer self-update
- mysql -e 'CREATE DATABASE forge;'

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Redis/Connections/PhpRedisConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function zrevrangebyscore($key, $min, $max, $options = [])
*/
public function zinterstore($output, $keys, $options = [])
{
return $this->command('zInter', [$output, $keys,
return $this->command('zinterstore', [$output, $keys,
$options['weights'] ?? null,
$options['aggregate'] ?? 'sum',
]);
Expand All @@ -284,7 +284,7 @@ public function zinterstore($output, $keys, $options = [])
*/
public function zunionstore($output, $keys, $options = [])
{
return $this->command('zUnion', [$output, $keys,
return $this->command('zunionstore', [$output, $keys,
$options['weights'] ?? null,
$options['aggregate'] ?? 'sum',
]);
Expand Down
20 changes: 14 additions & 6 deletions tests/Redis/RedisConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,25 +291,33 @@ public function test_it_calculates_union_of_sorted_sets_and_stores()

public function test_it_returns_range_in_sorted_set()
{
foreach ($this->connections() as $redis) {
foreach ($this->connections() as $connector => $redis) {
$redis->zadd('set', ['jeffrey' => 1, 'matt' => 5, 'taylor' => 10]);
$this->assertEquals(['jeffrey', 'matt'], $redis->zrange('set', 0, 1));
$this->assertEquals(['jeffrey', 'matt', 'taylor'], $redis->zrange('set', 0, -1));

$this->assertEquals(['jeffrey' => 1, 'matt' => 5], $redis->zrange('set', 0, 1, 'withscores'));
if ($connector === 'predis') {
$this->assertEquals(['jeffrey' => 1, 'matt' => 5], $redis->zrange('set', 0, 1, 'withscores'));
} else {
$this->assertEquals(['jeffrey' => 1, 'matt' => 5], $redis->zrange('set', 0, 1, true));
}

$redis->flushall();
}
}

public function test_it_returns_rev_range_in_sorted_set()
{
foreach ($this->connections() as $redis) {
foreach ($this->connections() as $connector => $redis) {
$redis->zadd('set', ['jeffrey' => 1, 'matt' => 5, 'taylor' => 10]);
$this->assertEquals(['taylor', 'matt'], $redis->ZREVRANGE('set', 0, 1));
$this->assertEquals(['taylor', 'matt', 'jeffrey'], $redis->ZREVRANGE('set', 0, -1));

$this->assertEquals(['matt' => 5, 'taylor' => 10], $redis->ZREVRANGE('set', 0, 1, 'withscores'));
if ($connector === 'predis') {
$this->assertEquals(['matt' => 5, 'taylor' => 10], $redis->ZREVRANGE('set', 0, 1, 'withscores'));
} else {
$this->assertEquals(['matt' => 5, 'taylor' => 10], $redis->ZREVRANGE('set', 0, 1, true));
}

$redis->flushall();
}
Expand Down Expand Up @@ -550,8 +558,8 @@ public function test_it_persists_connection()
public function connections()
{
$connections = [
$this->redis['predis']->connection(),
$this->redis['phpredis']->connection(),
'predis' => $this->redis['predis']->connection(),
'phpredis' => $this->redis['phpredis']->connection(),
];

if (extension_loaded('redis')) {
Expand Down

0 comments on commit 66b3188

Please sign in to comment.