mirror of
https://github.com/predis/predis.git
synced 2026-08-31 04:35:05 +00:00
Make HTTL and HPTTL commands Prefixable (#1639)
This commit is contained in:
committed by
GitHub
parent
6c9de258be
commit
4b527ba961
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user