mirror of
https://github.com/predis/predis.git
synced 2026-10-08 21:06:44 +00:00
Client handles -NOSCRIPT falling back to EVAL for scripted commands.
Now Predis\Command\ScriptedCommand uses EVALSHA instead of EVAL internally so that performances should be better since the client do not resend the Lua script body on each call. Plain EVALSHA commands are not affected and will return or throw the error.
This commit is contained in:
@@ -643,6 +643,31 @@ class ClientTest extends StandardTestCase
|
||||
$this->assertInstanceOf('Predis\Monitor\MonitorContext', $monitor = $client->monitor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testClientResendScriptedCommandUsingEvalOnNoScriptErrors()
|
||||
{
|
||||
$command = $this->getMockForAbstractClass('Predis\Command\ScriptedCommand');
|
||||
$command->expects($this->once())
|
||||
->method('getScript')
|
||||
->will($this->returnValue('return redis.call(\'exists\', KEYS[1])'));
|
||||
|
||||
$connection = $this->getMock('Predis\Connection\SingleConnectionInterface');
|
||||
$connection->expects($this->at(0))
|
||||
->method('executeCommand')
|
||||
->with($command)
|
||||
->will($this->returnValue(new ResponseError('NOSCRIPT')));
|
||||
$connection->expects($this->at(1))
|
||||
->method('executeCommand')
|
||||
->with($this->isInstanceOf('Predis\Command\ServerEval'))
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$client = new Client($connection);
|
||||
|
||||
$this->assertTrue($client->executeCommand($command));
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
|
||||
Reference in New Issue
Block a user