diff --git a/README.md b/README.md index 4a3afe2..2209ed5 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Currently supported commands: - SETEX - SETNX - GET +- MSET Installation: ``` @@ -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 diff --git a/src/Command/StringSetMultiple.php b/src/Command/StringSetMultiple.php index ddabe14..0be6b3a 100644 --- a/src/Command/StringSetMultiple.php +++ b/src/Command/StringSetMultiple.php @@ -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); } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 11f32dd..fa69161 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -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; @@ -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; @@ -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])); } }