Skip to content

Commit

Permalink
fix: mset command (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Anatoly Pashin <[email protected]>
  • Loading branch information
DinisEsteves and b1rdex authored Oct 15, 2024
1 parent b4916f4 commit 42e8cf1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Currently supported commands:
- SETEX
- SETNX
- GET
- MSET

Installation:
```
Expand Down Expand Up @@ -66,7 +67,7 @@ Default `GzipCompressor` uses [`gzencode`](http://php.net/gzencode) php function
You can create your own compressor by implementing `CompressorInterface`.

Roadmap:
- Add more commands (`MSET`, `HSET` and their get counterparts at least)
- Add more commands (`HSET` and their get counterparts at least)
- Make initialization simpler

[ico-license]: https://img.shields.io/github/license/b1rdex/predis-compressible.svg?style=flat-square
Expand Down
2 changes: 1 addition & 1 deletion src/Command/StringSetMultiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class StringSetMultiple extends BaseStringSetMultiple implements ArgumentsCompre

public function compressArguments(array $arguments): array
{
for ($i = 0, $count = \count($arguments); $i < $count; $i += 2) {
for ($i = 1, $count = \count($arguments); $i < $count; $i += 2) {
$this->compressArgument($arguments, $i);
}

Expand Down
5 changes: 4 additions & 1 deletion tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use B1rdex\PredisCompressible\Command\StringGetMultiple;
use B1rdex\PredisCompressible\Command\StringSet;
use B1rdex\PredisCompressible\Command\StringSetExpire;
use B1rdex\PredisCompressible\Command\StringSetMultiple;
use B1rdex\PredisCompressible\Command\StringSetPreserve;
use B1rdex\PredisCompressible\Compressor\ConditionalCompressorWrapper;
use B1rdex\PredisCompressible\Compressor\GzipCompressor;
Expand Down Expand Up @@ -66,6 +67,7 @@ private function getCompressedClient(): Client
$profile->defineCommand('SETNX', StringSetPreserve::class);
$profile->defineCommand('GET', StringGet::class);
$profile->defineCommand('MGET', StringGetMultiple::class);
$profile->defineCommand('MSET', StringSetMultiple::class);
}

return $profile;
Expand Down Expand Up @@ -190,7 +192,8 @@ public function it_should_allow_mset(): void
$value1 = 'value compressed1';
$value2 = 'value compressed2';
$value3 = 'value compressed3';
$sut->mset([$key1, $value1, $key2, $value2, $key3, $value3]);
$sut->mset([$key1 => $value1, $key2 => $value2, $key3 => $value3]);
self::assertSame([$value1, $value2, $value3], $sut->mget([$key1, $key2, $key3]));
self::assertNotSame([$value1, $value2, $value3], $this->getOriginalClient()->mget([$key1, $key2, $key3]));
}
}

0 comments on commit 42e8cf1

Please sign in to comment.