Make HTTL and HPTTL commands Prefixable (#1639)

This commit is contained in:
Vladyslav Vildanov
2026-02-17 19:12:12 +02:00
committed by GitHub
parent 6c9de258be
commit 4b527ba961
4 changed files with 43 additions and 1 deletions
+3
View File
@@ -3,6 +3,9 @@
### Unreleased
- Fixed getParameter() call on array + added integration testing with Sentinel (#2423)
### Added
- Make HTTL and HPTTL commands Prefixable (#1639)
## v3.4.0 (2026-02-11)
### Added
- Added optional 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;
class HTTL extends RedisCommand
{
@@ -28,4 +28,9 @@ class HTTL extends RedisCommand
parent::setArguments($processedArguments);
}
public function prefixKeys($prefix)
{
$this->applyPrefixForFirstArgument($prefix);
}
}
+17
View File
@@ -12,6 +12,8 @@
namespace Predis\Command\Redis;
use Predis\Command\PrefixableCommand;
class HPTTL_Test extends PredisCommandTestCase
{
/**
@@ -52,6 +54,21 @@ class HPTTL_Test extends PredisCommandTestCase
$this->assertSame(1, $command->parseResponse(1));
}
/**
* @group disconnected
*/
public function testPrefixKeys(): void
{
/** @var PrefixableCommand $command */
$command = $this->getCommand();
$command->setArguments(['key', ['field1', 'field2']]);
// After setArguments, the arguments are transformed to: ['key', 'FIELDS', 2, 'field1', 'field2']
$command->prefixKeys('prefix:');
$this->assertSame(['prefix:key', 'FIELDS', 2, 'field1', 'field2'], $command->getArguments());
}
/**
* @group connected
* @return void
+17
View File
@@ -12,6 +12,8 @@
namespace Predis\Command\Redis;
use Predis\Command\PrefixableCommand;
class HTTL_Test extends PredisCommandTestCase
{
/**
@@ -52,6 +54,21 @@ class HTTL_Test extends PredisCommandTestCase
$this->assertSame(1, $command->parseResponse(1));
}
/**
* @group disconnected
*/
public function testPrefixKeys(): void
{
/** @var PrefixableCommand $command */
$command = $this->getCommand();
$command->setArguments(['key', ['field1', 'field2']]);
// After setArguments, the arguments are transformed to: ['key', 'FIELDS', 2, 'field1', 'field2']
$command->prefixKeys('prefix:');
$this->assertSame(['prefix:key', 'FIELDS', 2, 'field1', 'field2'], $command->getArguments());
}
/**
* @group connected
* @return void