Fix eval_ro cluster support (#1449)

This commit is contained in:
zxin
2025-02-14 01:40:23 +08:00
committed by GitHub
parent 355faa099f
commit ac933cc548
3 changed files with 36 additions and 0 deletions
+2
View File
@@ -163,6 +163,8 @@ abstract class ClusterStrategy implements StrategyInterface
/* scripting */
'EVAL' => [$this, 'getKeyFromScriptingCommands'],
'EVALSHA' => [$this, 'getKeyFromScriptingCommands'],
'EVAL_RO' => [$this, 'getKeyFromScriptingCommands'],
'EVALSHA_RO' => [$this, 'getKeyFromScriptingCommands'],
/* server */
'INFO' => [$this, 'getFakeKey'],
@@ -231,6 +231,21 @@ class PredisStrategyTest extends PredisTestCase
}
}
/**
* @group disconnected
*/
public function testKeysForEvalReadOnlyCommand(): void
{
$strategy = $this->getClusterStrategy();
$commands = $this->getCommandFactory();
$arguments = ['%SCRIPT%', ['{key}:1', '{key}:2'], 'value1', 'value2'];
foreach ($this->getExpectedCommands('keys-script-ro') as $commandID) {
$command = $commands->create($commandID, $arguments);
$this->assertNotNull($strategy->getSlot($command), $commandID);
}
}
/**
* @group disconnected
*/
@@ -452,6 +467,8 @@ class PredisStrategyTest extends PredisTestCase
/* scripting */
'EVAL' => 'keys-script',
'EVALSHA' => 'keys-script',
'EVAL_RO' => 'keys-script-ro',
'EVALSHA_RO' => 'keys-script-ro',
/* server */
'INFO' => 'keys-fake',
@@ -246,6 +246,21 @@ class RedisStrategyTest extends PredisTestCase
}
}
/**
* @group disconnected
*/
public function testKeysForEvalReadOnlyCommand(): void
{
$strategy = $this->getClusterStrategy();
$commands = $this->getCommandFactory();
$arguments = ['%SCRIPT%', ['key:1'], 'value1'];
foreach ($this->getExpectedCommands('keys-script-ro') as $commandID) {
$command = $commands->create($commandID, $arguments);
$this->assertNotNull($strategy->getSlot($command), $commandID);
}
}
/**
* @group disconnected
*/
@@ -475,6 +490,8 @@ class RedisStrategyTest extends PredisTestCase
/* scripting */
'EVAL' => 'keys-script',
'EVALSHA' => 'keys-script',
'EVAL_RO' => 'keys-script-ro',
'EVALSHA_RO' => 'keys-script-ro',
/* server */
'INFO' => 'keys-fake',