Skip to content

Commit

Permalink
Fix RedisClient::getMultiple
Browse files Browse the repository at this point in the history
Re-applies 1eade91.

Co-authored-by: Dmitry Pilipenko <[email protected]>
  • Loading branch information
kelunik and d-pylypenko committed Aug 20, 2023
1 parent 453a3b1 commit 5c14a57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/RedisClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ public function incrementByFloat(string $key, float $increment): float
*/
public function getMultiple(string $key, string ...$keys): array
{
return \array_combine($keys, $this->execute('mget', $key, ...$keys));
\array_unshift($keys, $key);

return \array_combine($keys, $this->execute('mget', ...$keys));
}

/**
Expand Down
10 changes: 10 additions & 0 deletions test/RedisClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,15 @@ public function test(): void
$this->assertSame(4, $this->redis->increment('number'));
$this->assertSame(6, $this->redis->increment('number', 2));
$this->assertSame(1, $this->redis->getLength('number'));

$this->redis->set('multi.1', '1');
$this->redis->set('multi.2', '2');
$this->redis->set('multi.3', '3');

$this->assertSame([
'multi.1' => '1',
'multi.2' => '2',
'multi.3' => '3',
], $this->redis->getMultiple('multi.1', 'multi.2', 'multi.3'));
}
}

0 comments on commit 5c14a57

Please sign in to comment.