Make ZRANDMEMBER prefixable (#1621)

* Make ZRANDMEMBER prefixable

* Update CHANGELOG.md

---------

Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>
This commit is contained in:
Markus Reinhold
2025-12-23 12:27:27 +01:00
committed by GitHub
parent 980326d5d8
commit b211afd755
4 changed files with 29 additions and 1 deletions
+1
View File
@@ -4,6 +4,7 @@
### Fixed
- Fixed wrong `@param` annotation in `Parameters` (#1614)
- Make `ZRANDMEMBER` prefixable (#1621)
### Added
- Added retry support (#1616)
+6 -1
View File
@@ -12,7 +12,7 @@
namespace Predis\Command\Redis;
use Predis\Command\Command as RedisCommand;
use Predis\Command\PrefixableCommand as RedisCommand;
use Predis\Command\Traits\With\WithScores;
/**
@@ -33,4 +33,9 @@ class ZRANDMEMBER extends RedisCommand
{
return 'ZRANDMEMBER';
}
public function prefixKeys($prefix)
{
$this->applyPrefixForFirstArgument($prefix);
}
}
@@ -457,6 +457,10 @@ class KeyPrefixProcessorTest extends PredisTestCase
['key', 1.0, 'member'],
['prefix:key', 1.0, 'member'],
],
['ZRANDMEMBER',
['key', 10],
['prefix:key', 10],
],
['ZREM',
['key', 'member1', 'member2', 'member3'],
['prefix:key', 'member1', 'member2', 'member3'],
@@ -12,6 +12,7 @@
namespace Predis\Command\Redis;
use Predis\Command\PrefixableCommand;
use Predis\Response\ServerException;
class ZRANDMEMBER_test extends PredisCommandTestCase
@@ -93,6 +94,23 @@ class ZRANDMEMBER_test extends PredisCommandTestCase
$this->assertNull($redis->zrandmember($notExpectedKey));
}
/**
* @group disconnected
*/
public function testPrefixKeys(): void
{
/** @var PrefixableCommand $command */
$command = $this->getCommand();
$actualArguments = ['key', 10];
$prefix = 'prefix:';
$expectedArguments = ['prefix:key', 10];
$command->setArguments($actualArguments);
$command->prefixKeys($prefix);
$this->assertSame($expectedArguments, $command->getArguments());
}
/**
* @group connected
* @requiresRedisVersion >= 6.2.0