Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] Add Redis 5 support #29606

Merged
merged 3 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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